“File not found: lib” error while installing Rails 3.0.7

I was installing Rails 3.0.7 on my local machine yesterday and on a server today. I came across the same error both times:

This is the problematic part:

File not found: lib
ERROR:  While generating documentation for rails-3.0.7
... MESSAGE:   exit
... RDOC args: --ri --op /usr/local/rvm/gems/ruby-1.8.7-p334/doc/rails-3.0.7/ri lib --title rails-3.0.7 Documentation --quiet

Rails installed successfully but the Rdoc and ri documentation failed with this error. I ignored it in my local machine since I was in a hurry and Rdoc/ri were the least of my worries. But when it hapenned again in the server I just had to find out what the issue was. If you google it, many sources advise you to just uninstall that Rails version (in my case 3.0.7) and do this:

sudo gem install rails –no-ri –no-rdoc

I find that to be plain stupid! You are running away from the problem rather than solving it. The above command would just ignore the Rdoc/ri documentation.

The issue is that the new Rails version you are installing uses a more recent version of Rdoc/ri and thus when the installation process gets to Rdoc/ri installation, it fails. I don’t know why the ROR developers didn’t think of checking for this and updating Rdoc/ri for you. Anyway, the correct way to solve this issue is to first uninstall the Rails version you just installed with no Rdoc/ri data:

sudo gem uninstall rails –version 3.0.7

Install the latest version of the rdoc-data gem. This will install ri data for core and stdlib:

gem install rdoc-data

Then run:

rdoc-data –install

In case you want rdoc-data for all your gems run (not necessary.. takes a while if you have as many gems as i do):

gem rdoc –all –overwrite

To install ri data for RDoc 2.5+ run:

rdoc-data

Now you can install your Rails version and it will successfully install all the rdoc-data too.

sudo gem install rails

Output:

Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
Installing RDoc documentation for rails-3.0.7...

32 Comments

  1. I install ruby with rvm, but recently installing rails 3.0.9 on the most recent rvm gives me a headace when trying to resolv the problem of missing ‘lib’ directory. rdoc-data –install will complain about the directory missing: /home/ikon/.rvm/gems/ruby-1.9.2-p290/gems/rdoc-data-2.5.3/data/1.9.2
    I overcame with simply creating the missing end directory. Presto! Works 🙂 Hope it will help!

  2. I am trying to install Rails 3.0 on OS X Lion and I am getting the errors described in this post.
    But following the steps recommended I am getting an error on the “rdoc-data install” step. I get this error – “Could not find RubyGem rdoc-data”. If I run “gem list rdoc-data -d” it shows that the rdoc-data gem is installed and gives its location. Do you have any suggestions on how to get around this?

  3. I got same problem with Rails 3.1.0 but your solution didn’t work either. After running the steps in your post, on a last command ‘gem install rails’ it returned:

    Fetching: rails-3.1.0.gem (100%)
    Successfully installed rails-3.1.0
    1 gem installed
    Installing ri documentation for rails-3.1.0…
    file ‘lib’ not found
    Installing RDoc documentation for rails-3.1.0…
    file ‘lib’ not found

    what do you think?

  4. Oh well, it actually did waste my time to an extent, I kept trying to make work, it didn’t! and it was pretty awful trying to guess at appropriate commands to use for a windows installation. The main problem I guess was my version of rails (the latest currently, v3.2.8). Anyway, to cut a long story short, this whole hassle isn’t necessary anymore. I found a neat installer package; RailsInstaller, it comes with everything you need: Ruby, rails, sqlite, rvm etc. it even comes with git installed.

    Anyone who’s interested can find the package at http://railsinstaller.org/.

Did this waste your time or did you benefit from it? Let me know :-) Feel free to add your own views too