Whenever I try to install Rails on Ubuntu Server, I get the error, File not found: lib. Why is this?
-
2can you give us more details, stuff like how, when where.. Thanks – Rishav Rastogi Jan 27 '11 at 21:27
-
1Surely it says more than that. – Seth Jan 27 '11 at 21:27
-
1I typed "sudo gem install rails" it seemed to be installing and then it showed that error. Specifically it showed: Successfully installed rails-3.0.3 1 gem installed Installing ri documentation for rails-3.0.3... File not found: lib – Phil Jan 27 '11 at 21:28
-
use , `gem install rdoc` `gem install rails` – logan Apr 21 '15 at 10:26
6 Answers
Ubuntu 11.10, ruby 1.9.3p125, gem ruby 1.9.3p125
gem install rdoc
gem install rails

- 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
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:

- 1
- 1

- 4,635
- 2
- 35
- 21
-
1Pretty sure (in my case at least) it's actually `"/var/lib..."` instead of just `"/lib..."` – Mike Crittenden Mar 25 '11 at 18:17
-
1To 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
-
3Re 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
-
-
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
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!

- 1
- 1

- 29,907
- 37
- 114
- 158
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
# 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!

- 562
- 1
- 6
- 23
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.

- 75,850
- 13
- 131
- 154