Skip to content

Instantly share code, notes, and snippets.

@jcoglan
Last active January 4, 2016 20:39
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcoglan/8675825 to your computer and use it in GitHub Desktop.
Save jcoglan/8675825 to your computer and use it in GitHub Desktop.

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
@elskwid
Copy link

elskwid commented Jan 28, 2014

If you're binstub inclined you can also do:

bundle install --binstubs .bundle/bin --path .bundle

then add ./.bundle/bin to your $PATH

@elskwid
Copy link

elskwid commented Jan 28, 2014

That and I prefer https://github.com/postmodern/ruby-install/ to ruby-build mostly because it doesn't need to updated as often in my experience.

@mpapis
Copy link

mpapis commented Jan 28, 2014

using binstubs is a security issue when used with shared projects http://niczsoft.com/2013/10/please-hack-my-rails/

@elskwid
Copy link

elskwid commented Jan 29, 2014

@mpapis, thanks for that. I read the article when it came out and choose what projects get the binstub treatment in my environment. Great reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment