Rails: GemNotFoundException

For some reason, i could not find this information easily at one location, so i am dumping it here.

Running Ubuntu 7.10, i found myself re-installing ruby and rails on my system. Although prepackaged solutions containing both ruby and ruby on rails, i usually prefer to install ruby, and RubyGem, through my system’s package manager, and have gem freshly grab and install rails and all its dependencies.

So, here it goes:

  1. sudo -s … (this sends you to an admin mode so that you do not have to type sudo over and over again … do not abuse it and exit as soon as you are done)
  2. apt-get install ruby rubygem … should take care of installing ruby and rubygem on your system. (Debian system assumed, On SuSE Yast does that as well).
  3. gem install rails --include-dependencies … oh oh … Gem::GemNotFoundException … no rails !!!
  4. gem env … should show you your “GEM PATH” (in my case /var/lib/gems/1.8). In that directory, there is a source_cache file.
  5. rm /var/lib/gems/1.8/source_cache …. Delete that file!
  6. gem update … update your gem cache file
  7. gem install rails --include-dependencies … yaay it works
  8. exit … you must do this … do not abuse your root priviliges

This is it! The problem is that the stupid source_cache file is out of date and it needs to be resynchronized.

For some reason, after the successful installation i could not run the commands rails and rake directly from the console (without specifying the full path). This was because they were not added to /usr/bin. I didn’t bother googling for this because the solution is simple. If that happens with you, simply do the following:

  1. cd /usr/bin … this directory contains links to all your executable … do not mess with it … baby pandas will die if you do.
  2. sudo ln -s /var/lib/gems/1.8/bin/rails … this creates a symbolic link to rails … notice that the bin directory is in gem path specified by gem env.
  3. sudo ln -s /var/lib/gems/1.8/bin/rake … do the same for rake … it is useful.

This is it … i hope somebody finds it useful.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>