After installing Ruby and Ruby Gems:
$ sudo apt-get install ruby rubygems
...
$ ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
$ gem -v
1.3.7
If I try to install Rails I get an error, and even though it seems to be the documentation only, rails
isn't installed:
$ sudo gem install rails
...
Successfully installed rails-3.0.1
24 gems installed
...
Installing ri documentation for builder-2.1.2...
ERROR: While generating documentation for builder-2.1.2
... MESSAGE: Unhandled special: Special: type=17, text="<!-- HI -->"
... RDOC args: --ri --op /var/lib/gems/1.8/doc/builder-2.1.2/ri --title Builder -- Easy XML Building --main README --line-numbers --quiet lib CHANGES Rakefile README doc/releases/builder-1.2.4.rdoc doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.rdoc --title builder-2.1.2 Documentation
(continuing with the rest of the installation)
...
Installing ri documentation for rails-3.0.1...
File not found: lib
$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Ubuntu repositories only have Rails 2.3.5 so that isn't an option.
How do I get Rails to install properly?
Update: I tried the following, no error this time, but still no success:
$ sudo gem install rails --no-rdoc --no-ri
Successfully installed rails-3.0.1
1 gem installed
$ rails -v
The program 'rails' is currently not installed...
Update 2: So, thanks to Maran and Jörg, I now know the problem is not that rails
isn't installed, but it's not added to the PATH
. This can be fixed by adding the following to ~/.bashrc
:
export PATH=/var/lib/gems/1.8/bin:$PATH
That raises a further question: What should have added that to the PATH
? Presumably the apt-get install rubygems
? And what else may be broken?
Ok, I hesitated to use
rvm
as it seemed to be aimed at solving problems I didn't intend to have (multiple ruby versions? c'mon, I just want to play with rails...) and installing from source is generally something I want to avoid...Anyway, I gave in and followed along with http://rvm.beginrescueend.com/rvm/install/
Then (mostly suggested by the output of the above, but I needed to add
libmysqlclient-dev
):Then I edited my
.bashrc
as required and opened a new terminal.After creating a new project, I still had a few things to do to make it work:
And finally it all seems to be working. I hope that helps someone else, it certainly wasn't a particularly pleasant intro to a framework. I've reordered the commands I actually entered to avoid double handling for anyone following along.
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/:
try installing the rdoc gem first:
It worked for me using RVM on ruby 1.8.7 and rails 3.0.7
Good luck.
The Debian version of RubyGems installs Gems into
/var/lib/gems/1.8/
and Gem binaries into/var/lib/gems/1.8/bin
. You need to make sure that directory is in your$PATH
.This is a typical example of what I call the "If you hear hooves, think horses, not zebras" rule. If a computer tells you it cannot find something, the first thing to look for, is if that something is actually there, the second thing is whether the computer is looking in the right place. Installing
libreadline5-dev
OTOH is pretty far down the end of the list …In this case, you are telling the computer to execute the file
rails
in the$PATH
, which simply doesn't exist, because the directory it was installed into is not in the$PATH
.I documented the process I went through. It covers git, rvm, and vim.
http://appogee.posterous.com/ubuntu-1010-ruby-on-rails-setup
I'm guessing rails is installed just fine but the gem-folder is somehow not setup in your PATH. Do a search somewhat like this
find / -name *rails* | grep bin
and check if that yields any results; if so check if the path rails is located in is also in your PATH. (echo $PATH)