Sunday, April 29, 2012

Installing Ruby and Rails on Fedora with RVM


Please note, I'm using the Fedora 17 Beta, but this should work on older versions as well. Each of these commands should be run in a Terminal window.

First, ensure you have your Fedora install up to date:

sudo yum update

Next, let's install the prerequisites we will need:

sudo yum install git-core curl make bzip2 gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel libxslt-devel sqlite sqlite-devel openssl openssl-devel

We are now ready to install RVM:

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

...followed by,

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc

Optionally, you can add the following to the end of your .bashrc file to gain additional git features in your bash prompt:

PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

Finally, reload your .bashrc file with the following command:

. .bashrc

Ensure that RVM is loaded with the following command, which should output "rvm is a function":

type rvm | head -1

The following steps will install Ruby, Rails and the Sqlite3 gem. Execute these in order:

first,

rvm install 1.8.7

then...

rvm use 1.8.7 --default

and then...

rvm install 1.9.3

after that...

rvm use 1.9.3 --default

followed by...

gem install rails

...and finally,

gem install sqlite3

After that, check out some code and bundle it up (bundle install) or create a new rails app (rails new testapp).

13 comments:

  1. Thanks for the guide! As a note for people to prevent issues... these instructions are for a SINGLE USER install. so, only run the yum installer with sudo and ensure that you do NOT use root to install rvm. This means that you run bash -s stable |curl... as your user account.

    If you get a permission error, close out of your terminal window and reopen and try again. This should restore your settings so it's running as you. ("Exiting" out of a sudo session may not do the trick)

    ReplyDelete
  2. Curious to know why you first installed version 1.8.7 and then installed 1.9.3?

    ReplyDelete
  3. Ashwin, I wanted both installed - I have a project that is in 1.8.7 that I haven't converted just yet. It could probably be handled w/ a RVM Gemset though, I just do it this way. I'm sure there is a better way.

    ReplyDelete
  4. This is a good guide and did get me up and running. But I can't get WebBrick working, any advice on solving the ExecJS requirement??

    ReplyDelete
  5. Try adding

    gem 'execjs'
    gem 'therubyracer'


    to your Gemfile.

    ReplyDelete
  6. FYI:
    "Hello! The sqlite3-ruby gem has changed it's name to just sqlite3. Rather than
    installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
    dependencies accordingly.

    Thanks from the Ruby sqlite3 team!"

    ReplyDelete
  7. Thanks Jasper - I've updated the post.

    ReplyDelete
  8. Super stuff Jayson. Thanks much, saved me tons o' time!

    ReplyDelete
  9. Same here. Thanks! /me bookmarks

    ReplyDelete
  10. That .bashrc edit was terrific! Thanks

    ReplyDelete
  11. Thanks dude you are the supreme geek xD

    ReplyDelete
  12. hello, i add into .gemrc the next 2 lines

    install: --no-rdoc --no-ri
    update: --no-rdoc --no-ri


    ReplyDelete
  13. if people are getting errors on rvm install x try --> sudo chown -R USERNAME /usr/local/rvm

    ReplyDelete