Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Ruby on Rails 3.0 on Ubuntu 10.10?

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?

like image 599
Tom Avatar asked Nov 11 '10 06:11

Tom


2 Answers

I very strongly suggest you skip the Ubuntu packages and use RVM. The install process is pretty straight forward and documented. There is also a Railscast on it.

RVM will allow you to install multiple versions and create custom gemsets (no dependency problems). It is WELL worth it and quickly becoming the de-facto way to develop (and deploy) with Ruby.

like image 64
Jim Mitchener Avatar answered Sep 23 '22 22:09

Jim Mitchener


http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/:

Under no circumstance should you install Ruby, Rubygems or any Ruby-related packages from apt-get. This system is out-dated and leads to major headaches. Avoid it for Ruby-related packages.

like image 42
Tom Avatar answered Sep 25 '22 22:09

Tom