Unistall rvm
( if there exists one )
rm -rf ~/.rvm
\curl -sSL https://get.rvm.io | bash -s stable
- Add .rvm/bin to your path
export PATH=$HOME/.rvm/bin:$PATH
- Load
rvm
as a function
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
- Make sure that the above two steps happen only once in your bash/zsh profile
rvm list known
gives the list of known rubies- Install a particular ruby using
rvm install <ruby-version>
- Example :
rvm install ruby-2.1.1
- Create gemsets for every fricking project.
- Never install global gems
- To create a gemset for version
2.1.1
rvm use ruby-2.1.1
rvm gemset create project_name
- As simple as that
rvm gemset_name
can be run to use a particular gemset
rvm ruby-2.1.1@gemset_name
- Create a
.ruby-version
file in the root of the project. It should contain the ruby version being used for the project
echo "ruby-2.1.1" > .ruby-version
- Create a
.ruby-gemset
file in the root of the project. This file should contain the name of the gemset used for this project. Typically it is the same as the project name.
echo "project_gemset" > .ruby-gemset
- The following command can be run to create gemsets and the
.rvmrc
file for projects
rvm ruby-2.1.1@my_project --create --rvmrc
- Note : This is not compatible with other ruby version managers. Use this only if you are planning to use rvmrc.
- Create a
Gemfile
in your project
source 'https://rubygems.org'
gem 'rails'
- Use
bundle
to install the required gems
bundle install
-
This creates a
Gemfile.lock
which is a locked version of all gems and their versions and dependencies. -
Execute a gem in the bundler's environment using
bundle exec
bundle exec rspec spec/models
rvm use --default 2.1.1
rvm get stable