开发者

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)
...
Installi开发者_如何学运维ng 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?


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.


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.


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/

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

Then (mostly suggested by the output of the above, but I needed to add libmysqlclient-dev):

$ sudo aptitude install build-essential bison openssl libreadline5 \
                        libreadline5-dev curl git zlib1g zlib1g-dev \
                        libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 \
                        libxml2-dev libmysqlclient-dev

Then I edited my .bashrc as required and opened a new terminal.

$ rvm install 1.9.2
$ rvm --default use 1.9.2
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
$ gem install rails
$ rails -v
Rails 3.0.1

After creating a new project, I still had a few things to do to make it work:

$ rails new myproject --database=mysql
$ cd myproject
$ emacs config/database.yml # set passwords
$ bundle install
$ rake db:create
$ rails server

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.


try installing the rdoc gem first:

gem install rdoc

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'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)


I documented the process I went through. It covers git, rvm, and vim.

http://appogee.posterous.com/ubuntu-1010-ruby-on-rails-setup


You will need a bunch of building tools. Googling "install rails 3.0.1 ubuntu" and you will find the info. It will be something like:

apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline5-dev

Also recommended is RVM, which is very good for having multiple Ruby versions and different gem sets, good for experimenting and for using different versions of Rails on the same machine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜