08 10 / 2012

This isn’t about the material riches obtained over time, but about the shared wealth among the Ruby community ;)

In case you notice that suddenly all your gems vanish from your system, and “gem list” shows none of the gems that you had installed previously, the details below can help you. In retrospect, I remembered that this was a result of gem update —system,that I had executed some time back. It updated rubygems version, as well as the ruby version used by rubygems, and it was a clean slate (I don’t know why they mention that command before installing a gem, in documentation. It can ruin your day!).

So effectively, I had two executables - gem1.8 and gem1.9.1 in my bin directory. The update had made a soft link: /usr/bin/gem -> /usr/bin/gem1.9.1. You can check which executable is being used by doing which gem, and then ls -al <gem path> to get the executable.

$ gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i686-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /var/lib/gems/1.9.1
     - /home/amit/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
$ gem1.8 env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.15
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-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/amit/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

The Fix:

Create a soft link for the gem1.8 executable, and everything will be as it was:

rm usr/bin/gem

ln -s /usr/bin/gem1.8  /usr/bin/gem

Back to the good old days! I’ll save the rubygems update for some other day, and I dread gem update —system form now on…. :O :O :O

blog comments powered by Disqus