backbone.ws

This is an old revision of the document!


RVM

Usage

Installation

  1. \curl -L https://get.rvm.io | bash -s stable - install stable version
  2. Add to ~/.zshrc, ~/.bashrc:

    ~/.zshrc and ~/.bashrc

    export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
    [[ -r $HOME/.rvm/scripts/completion ]] && . $HOME/.rvm/scripts/completion
  3. Logout/Login to complete the installation.

Get State

  • rvm list - show currently installed rubies;
  • rvm list known - show all known RVM installable Rubies;
  • rvm gemset list - list installed gemsets for selected Ruby version;
  • rvm info - show the current environment information for current ruby;
  • rvm gemdir - gem directory of the currently selected ruby.

Install Ruby

  1. rvm install 1.9.3 --autolibs=read-only - install Ruby of specific version;
  2. rvm gemset create rails3myproject - creates gemset with rails3myproject name;
  3. rvm use 1.9.3@rails3myproject --default - use Ruby 1.9.3 with rails3myproject gemset for new shells;
  4. rvm rubygems current or rvm rubygems latest - install the most recent RubyGems that RVM knows about;
  5. rvm rubygems 1.8.29 - install version 1.8.29 of RubyGems;
  6. gem install rails -v 3.2.15 - install specific rails in current gemset;
  7. gem install bundler - install Bundler;
  8. rvm use 1.9.3@rails3 --create --default - short way to create and use specific Ruby&Rails for current and new shells;
  9. rvm wrapper ruby-name - create symlinks in ~/.rvm/bin for specific Ruby version;
  10. rvm wrapper default --no-prefix - create symlinks in ~/.rvm/bin for default Ruby version.

Upgrading

  • rvm get stable - update to the latest stable version

Remove Unused

  • rvm gemset delete rails2 - remove the entire gemset directory 'rails2';
  • rvm rubygems remove - remove the different version installed of RubyGems;
  • rvm uninstall 1.8.7 - uninstall Ruby-1.8.7 but keep sources;
  • rvm remove 1.8.7 - uninstall Ruby-1.8.7 with sources.
  • gem pristine charlock_holmes - removes charlock_holmes gem

Useful Commands

  • rvm reset - reboot RVM;
  • rvm implode - fully remove RVM;
  • rvm use system - use System's Ruby version;
  • rvm gemset export - export gemset to default.gems;
  • rvm gemset import default.gems - install gemset from default.gems list.

Separate Ruby for Projects

Create $project/.rvmrc file with rvm use RubyVersion@projectname for example rvm use 1.9.3@rails3.

Typical Scanarios

Redmine / Gitorious installations:

Redmine/Gitorious deployments

curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm reload
rvm install 2.0.0 --autolibs=read-only # Gitorious only
rvm install 2.1.10 --autolibs=read-only # Redmine only
rvm use 2.0.0@global --create --default # Gitorious only
rvm use 2.1.10@global --create --default # Redmine only
gem uninstall bundler; gem install bundler -v '< 1.12' # Temporary workaround: 1.12.3 requires to unlock nproc limits protection
rvm wrapper default --no-prefix ; rvm wrapper default --no-prefix bundle # updates symlinks in ~/.rvm/bin
gem install unicorn # Gitorious only
cd site && bundle install --deployment # Gitorious only
cd redmine && bundle install --no-deployment --without development test # Redmine only
paxctl -m `which ruby` # Hardened Gentoo only