I’ve heard people describe frustrations they had in getting Rails 3 setup on Ubuntu 10.04 with Ruby 1.9.2. I’m going to outline the steps I’ve taken to do this. Let’s get started installing RVM.
It should be noted that I created a fresh slice on my Rackspace Cloud account to create this tutorial. And I’m assuming you’ve already setup SSH.
<-- Output Snipped -->
root@173.XXX.XXX.XXX's password:
<-- Output Snipped -->
Alright, so lets confirm we don’t have ruby installed
$
Cool, nada. Let’s grab the basic dependencies
Reading package lists... Done
Building dependency tree
<-- Output Snipped -->
Now we’ll install RVM as per their instructions
http://rvm.beginrescueend.com/rvm/install/
<-- Output Snipped -->
RVM: shell scripts which allow management of multiple ruby interpreters and environments.
RTFM: http://rvm.beginrescueend.com/
HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
* Installing rvm to /usr/local/rvm/
Correct permissions for base binaries in /usr/local/bin...
Copying manpages into place.
Notes for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS" )
<-- Output Snipped -->
* For JRuby (if you wish to use it) you will need:
$ aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk
* For MRI & ree (if you wish to use it) you will need (depending on what you are installing):
$ aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf
* For IronRuby (if you wish to use it) you will need:
$ aptitude install curl mono-2.0-devel
<-- Output Snipped -->
WARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc.
This means that if you see '[ -z "$PS1" ] && return' then you must change this line to:
if [[ -n "$PS1" ]] ; then
... original content that was below the && return line ...
fi # <= be sure to close the if.
#EOF .bashrc
Even if you use zsh you should still adjust the .bashrc as above.
If you have any questions about this please visit #rvm on irc.freenode.net.
Installation of RVM to /usr/local/rvm/ is complete.
The last part in there about the .bashrc file is important! Using your editor of choice, open the .bashrc file that resides in your user directory.
You need to replace the line that says
[ -z "$PS1" ] && return
with
if [[ -n "$PS1" ]]; then
Now add this to the last line of the file
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi fi
And yes there needs to be that last fi as it closes the one we added earlier. Save this file with our changes. Now we can check if RVM is setup correctly.
If this doesn’t work you may have to source your .bashrc file to have it reloaded by the current terminal session
After running `rvm notes` if it gives you installation notes about RVM then you’re good to continue, otherwise double check you edited your .bashrc file correctly.
In the notes output RVM tells you what packages you’re gonna need to install for various flavors of Ruby. Since we’re going with 1.9.2 we want the packages it lists under the MRI & ree section. Let’s install those now.
<-- A really long bit of Output Snipped -->
Now we can look at all the RVM known Ruby packages
# MRI Rubies
(ruby-)1.8.6(-p399)
(ruby-)1.8.6-head
(ruby-)1.8.7(-p302)
(ruby-)1.8.7-head
(ruby-)1.9.1-p243
(ruby-)1.9.1-p376
(ruby-)1.9.1(-p429)
(ruby-)1.9.1-head
(ruby-)1.9.2-preview1
(ruby-)1.9.2-preview3
(ruby-)1.9.2-rc1
(ruby-)1.9.2-rc2
(ruby-)1.9.2(-p0)
(ruby-)1.9.2-head
ruby-head
# JRuby
jruby-1.2.0
jruby-1.3.1
jruby-1.4.0
jruby-1.5.1
jruby(-1.5.2)
jruby-head
<-- Output Snipped -->
Next we install the version we want and set it as the default. You’re gonna see RVM install ruby-1.8.7-p302 first, be patient as it will need to also install rubygems-1.3.7, before it finally gets to that 1.9.2.
<-- Output Snipped -->
info: Installing ruby-1.8.7-p302
<-- Output Snipped -->
info: Installing rubygems dedicated to ruby-1.8.7-p302...
<-- Output Snipped -->
info: Installing ruby-1.9.2-head
<-- Output Snipped -->
info: Updating rubygems for /usr/local/rvm/gems/ruby-1.9.2-head
$ ruby -v
$ ruby 1.9.2p0 (2010-08-18 revision 29034) [x86_64-linux]
Good to go.
{ 71 comments… read them below or add one }
Next Comments →
I found it very useful.
Thank & keep on the good job.
bye luca
Nice post, really useful, please continue with the install of rails 3 final.
Now that it is released the need for good tutorials is even more
I really like the clarity of your instructions. I hope you get the article on settings up Rails 3 posted soon. In the meantime I’ll snapshot my VM and wander in the dark trying random methods of installation. Thanks
Hey Chris,
Thanks for consolidating at one place all thats needed to install ruby on Linux. I followed your instructions and successfully installed rvm and ruby on my machine (ubuntu 10.04). I also installed rails by executing the following command that I found out from elsewhere on the net:
gem install rails –pre
after the installation I created a directory rubydev in my home folder (/home/alwin) and then successfully created a dummy web application in it using the command:
~/rubydev$ rails new hello
when I try to execute the command “ruby script/generate controller App” from the folder “~/rubydev/hello”, it gave the error “ruby: No such file or directory — script/generate (LoadError)”
Please help me fix this problem.
Some of the commands which can be relevant in this situation and their respective outputs for my machine are as under:
~$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29034) [i686-linux]
~$ which ruby
/home/alwin/.rvm/rubies/ruby-1.9.2-head/bin/ruby
~$ echo $PATH
/home/alwin/.rvm/gems/ruby-1.9.2-head/bin:/home/alwin/.rvm/gems/ruby-1.9.2-head@global/bin:/home/alwin/.rvm/rubies/ruby-1.9.2-head/bin:/home/alwin/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Thanks in advance
Alwin
Thanks, exactly what I was looking for.
Thanks a lot , I was having some troubles with the .bashrc , but I got it here
Thanks a lot, this was really helpful for me!
Good stuff, exactly what I needed! Thanks for taking the time to document the process.
This helps a lot!
maybe you could add, that after editiinf the .bashrc you have to do the rvm check in a new terminal window.
Thanks! This was very helpful.
Doesn’t quite work for me.
Everything goes great until I run “rvm install 1.9.2-head”. I see no output from the command. Instead, bash shells are created (many per second) until the machine runs out of resources and stops updating the screen. Here is a sample of the “ps aux” output:
sweber 6483 0.0 0.5 5344 2548 pts/0 S+ 17:55 0:00 bash /home/sweber/.rvm/scripts/manage install 1.9.2-head
sweber 6526 0.0 0.3 5344 1848 pts/0 S+ 17:55 0:00 bash /home/sweber/.rvm/scripts/manage install 1.9.2-head
sweber 6534 0.0 0.5 5344 2548 pts/0 S+ 17:55 0:00 bash /home/sweber/.rvm/scripts/manage install 1.8.7
sweber 6577 0.0 0.3 5344 1848 pts/0 S+ 17:55 0:00 bash /home/sweber/.rvm/scripts/manage install 1.8.7
I’ve tried several variations on the .bashrc edit. Other sources seem to suggest that the sourcing lines should be outside the instructions bracketed by the “if”. Same results.
Great post, very thorough! It’s exactly what I was looking for too, only exception being that I’m using Ubuntu 10.10, but all the instructions worked perfectly. Thanks!
It’s strange, I’ve followed al the steps, but “$ruby -v” returns “ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]“. That’s not the same is it?
What happens when you do
I ran into this same problem. ‘rvm list’ shows the 1.8.7 ruby I installed, but if I ‘rvm use 1.8.7′ then ‘ruby -v’ I still get the linux system ruby. ‘which ruby’ always returns /usr/bin/ruby.
Wayne pointed me to the solution on #rvm. Needed to replace $HOME/.rvm/ with /usr/local/rvm/ as I was root http://rvm.beginrescueend.com/rvm/basics/
Thanks for this blogpost.
This was _exactly_ what I needed! Good work, and thanks!
I’m afraid it doesn’t work for me:
echo executable host ruby is required. use –with-baseruby option.; false -I. ./tool/compile_prelude.rb ./prelude.rb miniprelude.c
executable host ruby is required. use –with-baseruby option.
Further to previous comment where it didn’t work using:
rvm install 1.9.2-head
It does work if I use the command without -head ie:
rvm install 1.9.2
Hmm… perhaps 1.9.2 head isn’t at a stable version now??
Needs to be: rvm install 1.9.2–head
Note the double dashes.
When i do: rvm install 1.9.2–head
i get the same error. So, I installed without -head now.
$ rvm –default 1.9.2–head – Doesn’t actually set –default for me.
This does though:
$ rvm 1.9.2–head –default
Thanks for the tutorial. Really helped. Wish RVM came as a default package in Ubuntu.
This is one where you have to sort of take a serious look at the documentation, sometimes I get complacent with aptitude…
The docs instruct that you simply change the ‘return’ line to:
[code]if [[ -n "$PS1" ]]; then
# Some code here... e.g.
export HISTCONTROL=ignoreboth
fi
[/code]
and then add [code][[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
[/code]
A restart of bash yielded great success…
Great stuff! I’ve referenced it twice so far and it’s worked perfectly.
Thank you very much for this, I tried once before but gave up. This went without a hitch.
Thank you very much for this installation guide. Without this guide I would never have put the correct content into the .bashrc. Did you already told the rvm developer about that?
Thank you for the simple and elegant tutorial.
Thank you for this guide.
Thanks!
I was having all sorts of issues until I read this.
Great, very helpfull!!!
Thanks a lot
Thanks man!
Thanks!
your instructions worked perfectly!
ubuntu 10.10, ruby 1.9.2, rails 3.0.5
Very useful, thanks! One minor point – in my .bashrc file the `[ -z "$PS1" ] && return` line wasn’t at the end, it was in the middle somewhere. So rather than replacing it, i deleted it and then pasted the other three lines at the bottom.
The rvm curl snippet should use https now, the old one no longer works.
bash < <( curl https://rvm.beginrescueend.com/releases/rvm-install-head )
Ah, thanks, post updated.
Nice article. Works for me at first go. Thanks a ton for sharing. Was struggling, to setup RVM on Ubuntu.
- Puneet
Thank you sir.
This is massively useful, thank you.
Strictly speaking, you should not need ruby in the dependencies, should you?
Other than that, nice tutorial.
Hi,
I found your article very useful. I’m trying to install RVM on ubuntu 11.0.4 using virtual box on Windows 7. Even after accomodating all changes you suggested I’M STILL GETTING RVM: NOT FOUND.
Can you please suggest me the sloution, I’m new to Ubuntu.
Really simple, thanks very much.. )
Thanks a lot!
Ubuntu 10.10, ruby 1.9.2 worked perfectly!
Thank you for this guide…………………………..
Awesome. Worked on 11.04 x32.
Thanks!! worked on 11.04 x32 for me too. Saved me alot of time
Thanks dear just installed and configured rvm on Ubuntu 11. This is wonderful guide.
Worked like a charm, thanks!
Hi! Thanks for this guide, very useful! Only one suggest: I’m using Linux Mint 11 and .bashrc file doesn’t exist, I created manually. An hint for this case can be a good idea for other peoples like me.
Chris,
Great step-by-step post and really relevant. Helped me save the issue with my ubuntu rvm install. you’da man!
This Post was very very useful to me.
Thanks alot
Bye
Vinothini, spritle
Really useful post, thanks a lot!
Maybe it helps someone. I have issue with rvm installation: rvm command wasn’t work. But I did like it says in tutorial above.
My fail was that I did like in this tutorial + edited bash_profile from another. So check this file and clean it. For me it works!
There is now an updated install script, the one above no longer works:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Thanks for the tip, I’ll update the post tonight
This post once helped me. Thanks Irish.
nice page,
please update the url to install rvm. it is not working.
i tried with ubuntu 10.04
correct one is
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
This is the only tutorial that really helped me get rails working on my computer and my friend’s computer, Thanks so much.
Works great. Thanks
Next Comments →
{ 7 trackbacks }