31

Whenever I try to install Rails on Ubuntu Server, I get the error, File not found: lib. Why is this?

Phil
  • 311
  • 1
  • 3
  • 3

6 Answers6

34

Ubuntu 11.10, ruby 1.9.3p125, gem ruby 1.9.3p125

gem install rdoc
gem install rails
imwilsonxu
  • 2,942
  • 24
  • 25
  • The mkdir business is too obscure... different unixes (Mac OS has its own path, etc). Install rdoc first worked for me on a fresh (non-rvm) ruby install of 1.9.3-p194 and rails 3.2.3 – pedz May 19 '12 at 13:23
  • 1
    This worked for me on OSX 10.7 :) – gawbul Jan 02 '13 at 15:39
17

I had the exact same problem. I tried the other solution suggested here and that didn´t work for me on Ubuntu.

Here is the solution:

Ubuntu

mkdir /lib/ruby/gems/1.8/gems/rails-{whatever your version is}/lib

Depending on which combination of environment versions you're using, some users have given the feedback that this works for them instead:

mkdir /var/lib/gems/1.8/gems/rails-{whatever your version is}/lib

Basically, the ¨[sudo] gem install rails¨ command expects the /lib folder (at the end) but for some reason it hasn´t been created yet.

If you're not sure what your rails version is for the part where I say {whatever your version is}, type up to "rails-" and then try hitting the tab button. You're on a Linux system, so it'll give you a suggestion or two. If it doesn't, try the alternative line given above. You'll need some try and error here because the directory structure is slightly varied in different versions of rails, it seems.

The source of this solution was the following URL. Hope it helps!

http://www.spritle.com/blogs/?p=915

Mac OS X

If you're having a similar problem on Mac OS X, take a look at this other post as well. Sounds like your work-around is simpler:

Ruby on Rails Beta 3 Install Problem on Snow Leopard

Community
  • 1
  • 1
Amin Ariana
  • 4,635
  • 2
  • 35
  • 21
  • 1
    Pretty sure (in my case at least) it's actually `"/var/lib..."` instead of just `"/lib..."` – Mike Crittenden Mar 25 '11 at 18:17
  • 1
    To make this answer more useful you should include how to get the value for {whatever your version is} – Luke Foust May 14 '11 at 17:35
  • 3
    Re the /var/, it's actually not /var/lib/ruby/gems but /var/lib/gems/.. I HATE THE INCONSISTENT *NIX FILE HIERARCHY. But after the creation of four different directory trees I finally got this to work. – Jon Davis May 16 '11 at 02:17
  • Thank you Simypy77, that solved the problem on ubuntu 11.04 – Antony Jul 16 '11 at 01:32
  • In Amazon EC2's Linux distribution it appears to be /usr/lib/ruby/gems/1.8/gems/rails-3.1.0/lib that's missing. – Miles Erickson Sep 24 '11 at 00:33
  • `mkdir .rvm/gems/ruby-1.9.2-p290/gems/rails-3.1.0/lib` worked for me, but I had to run it just after the rails gem is installed and the documentation begins to install – Daniel Oct 07 '11 at 00:27
5

Google has lots of information about this error. You can read this or this..or browse more

EDIT

Found these on Stackoverflow itself: rails 3 install error "File not found: lib" and the original one: Ruby on Rails Beta 3 Install Problem on Snow Leopard

To summarize you need to run gem install rdoc before.

It might solve your problem!

Community
  • 1
  • 1
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
4

I had the same problem. I kept receiving the following error message:

$ sudo gem install rails
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
File not found: lib

After a lot of messing around reinstalling ruby and googling for answers I finally came across Amin Ariana's answer, upon which I ran sudo mkdir /var/lib/gems/1.8/gems/rails-3.0.7/lib/.

Success! Everything now works as expected:

$ sudo gem install rails
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...

According to a similar StackOverflow answer, running sudo gem install rdoc has the same effect.

NOTE: To actually run rails after installing via gem rather than apt, you'll need to add the gem library to your path in your ~/.bashrc: /var/lib/gems/1.8/bin

Community
  • 1
  • 1
Zaz
  • 46,476
  • 14
  • 84
  • 101
0
# sudo gem install rdoc
# sudo gem install rdoc-data
# sudo vim /var/lib/gems/1.8/gems/rdoc-data-2.5.3/bin/rdoc-data

rdoc-data version 2.5.3 is depend on your version. My Marveric ruby path is /usr/bin/ruby, But my rdoc-data ruby path wasn't. Then I change it.

EDIT/

#!/usr/bin/ruby -w

require 'rubygems'
require 'rdoc/data'

RDoc::Data.run

/EDIT

# sudo /var/lib/gems/1.8/gems/rdoc-data-2.5.3/bin/rdoc-data --install
# sudo gem rdoc --all --overwrite
# sudo mkdir -p /var/lib/gems/1.8/gems/rails-3.0.6/lib
# sudo gem rails

Good luck!

tknv
  • 562
  • 1
  • 6
  • 23
0

As I understand it, the actual issue lies within rubygems:

https://github.com/rails/rails/issues/1958

https://github.com/rails/rails/commit/e7fc5d1cad27e47d3d0149a2b9a61d074c30f225

The default s.require_paths is, in as far as I can tell by the commit to fix the issue, [lib] rather than []. So you end up with lib not found errors whenever you install a gem without such a folder.

Rails in particular, but not only.

Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154