tags:

views:

943

answers:

1

How does "gem install" works ? It is not intuitive...

My gem is really here :

[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 ? Thx JC

+1  A: 

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:

  1. require 'rubygems'
  2. require 'rubygems/gem_runner'
  3. #Gem.manage_gems
RedFred
I'm trying to install a gem from source, how would I do that? Preferably with a symlink so I can update the source.
Pepijn