Skip to content
Chris Smith edited this page Nov 8, 2013 · 61 revisions

RVM

To install RVM, but be sure to double check with the RVM installation instructions

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

Note that using sudo or being logged in to the root account will install RVM system-wide (i.e. for all users/apps), which is probably what you want.

Also, you can decide for each rails app what ruby version and gemset it will use by creating a .rvmrc in the app's root (i.e. Rails.root) folder.

Verify RVM requirements are met

rvm requirements

then compare the output to the libraries and build tools that were installed during add packages, libraries, and build tools needed by other software installations on the wiki home page.

Add the user that the rails app runs as to the rvm group

The rails app should run as a particular user (not root) and that user should be added to the rvm group:

sudo adduser the_user_your_rails_app_will_be_running_as rvm

Trusting .rvmrc files

When various ruby scripts run as services (i.e. in the background) there is no one there to answer the rvm question 'do you trust this .rvmrc file?'.

A global setting is needed to trust all .rvmrc files in the rails apps, so edit the /etc/rvmrc file:

sudo nano /etc/rvmrc

then add the following line:

rvm_trust_rvmrcs_flag=1  

and save. Without this change, processes such as Passenger, Thin, Unicorn, cron, and so on will silently hang and such errors are hard to detect.


From this point forward, avoid doing any rvm commands as root or sudo instead do all commands as the_user_your_rails_app_will_be_running_as.


Use rvm to install Ruby (note that installing ruby takes a very long time):

rvm list known
rvm install ruby-2.0.0

Use rvm to set the default ruby:

rvm --default use 2.0.0

Set up the global gemset for all apps

rvm gemset use global 
rvm gemset name ... verify the gemset is global
gem install bundler --no-ri --no-rdoc
gem install foreman --no-ri --no-rdoc

Optionally you may want to install one of these app servers:

gem install passenger --no-ri --no-rdoc
gem install thin --no-ri --no-rdoc
gem install unicorn --no-ri --no-rdoc

To list the gems installed in the global gemset do:

gem list

To start over at any time, the following will uninstall rvm, any rubies, and gems:

rvm implode ... or ... rvmsudo implode  ... if rvm alone doesn't work

Note that for all of the above to take effect the server will need to be rebooted.