How does "gem install" works ? It is not intuitive...
My gem is really here :开发者_StackOverflow
[root@localhost Téléchargement]# ll *.gem
-rw-rw-r-- 1 jean jean 16353818 mar 5 11:39 ruby-processing-1.0.9.gem
But an idiomatic "gem install" does not see it...
[root@localhost Téléchargement]# gem install ruby-processing-1.0.9.gem
ERROR: could not find gem ruby-processing-1.0.9.gem locally or in a repository
What's wrong with that ?
Maybe I have not fully understood the question. But if you just want to install a gem that you have on your local machine, all you need to do from the console is go into the directory containing your gem and gem install --local your.gem
.
Just some more clarification in case you need to build / install your own gem file in this example foo-bar.
gem build foo-bar.gemspec
gem install --local foo-bar-0.1.0.gem
I was researching how to do this and this post was first result :)
The problem is that gem install is looking for gems to install in its default directory. You can find out where that is by running:
$ gem environment
This will give you something like:
> RubyGems Environment:
> - RUBYGEMS VERSION: 1.3.6
> - RUBY VERSION: 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
> - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
> - RUBY EXECUTABLE: /usr/bin/ruby1.8
> - EXECUTABLE DIRECTORY: /usr/bin
> - RUBYGEMS PLATFORMS:
> - ruby
> - x86-linux
> - GEM PATHS:
> - /usr/lib/ruby/gems/1.8
> - /home/adminuser/.gem/ruby/1.8
The GEM PATHS locations is where gem install is expecting to find gems to install. So, the solution to your problem would be to copy the gem from its current location to the expected directory, i.e.
$ cp my.gem /home/adminuser/.gem/ruby/1.8/
If you then run gem install it will pick up your gem and install it. Make sure you run the copy command as superuser (sudo, if you're running Ubuntu like me)
P.S If, when you run $ gem environment, you get an "undefined method ‘manage_gems’ for Gem:Module (NoMethodError)" error, then edit /usr/bin/gem and ensure that the first three lines of the file look like this:
- require 'rubygems'
- require 'rubygems/gem_runner'
Gem.manage_gems
精彩评论