First, you install ruby-build and chruby. ruby-build is a program that knows how to download and build different ruby versions. chruby manages $PATH
to control which ruby
gets invoked in your shell. They work completely independently.
sudo su
cd /usr/src
git clone https://github.com/sstephenson/ruby-build.git
cd ruby-build
./install.sh
cd -
wget -O chruby-0.3.8.tar.gz https://github.com/postmodern/chruby/archive/v0.3.8.tar.gz
tar -xzvf chruby-0.3.8.tar.gz
cd chruby-0.3.8
make install
cd -
Then you install a rubby (still as root). chruby expects rubbies to live in /opt/rubies
. I install bundler
globally and install each project's deps inside the project with bundle --path
.
mkdir -p /opt/rubies
ruby-build 2.1.0 /opt/rubies/2.1.0
/opt/rubies/2.1.0/bin/gem install bundler
Then you put chruby 2.1.0
in your .bashrc
and work on projects like this:
bundle --path .bundle
bundle exec rspec
using binstubs is a security issue when used with shared projects http://niczsoft.com/2013/10/please-hack-my-rails/