Skip to content

Instantly share code, notes, and snippets.

@gma
Forked from rtomayko/gist:74683
Created March 6, 2009 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gma/74848 to your computer and use it in GitHub Desktop.
Save gma/74848 to your computer and use it in GitHub Desktop.
# This isn't as elegant as some of the other solutions for running multiple versions
# of Ruby but it's simple, straight-forward and has worked well for me so far. I'm
# currently running the most recent stable versions of 1.8.5, 1.8.6, 1.8.7, and
# 1.9.1 and plan to experiment with some patched versions as well.
# pull one of the tarballs down and extract:
$ cd /tmp
$ curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz |
tar xvzf -
$ cd ruby-1.9.1-p0
# make and install under /opt/rubyVERSION:
$ configure --prefix=/opt/ruby19
$ make && sudo make install
# create a script that sets up the PATH and invokes the command given on argv:
$ cat <<'EOF' > ~/bin/ruby19
PATH="/opt/ruby19/bin:$PATH"
export PATH
exec "$@"
EOF
$ chmod +x ~/bin/ruby19
# run stuff by prefixing everything with "ruby19"
$ ruby19 ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.5.0]
$ ruby19 irb
# install gems under that version of ruby:
$ ruby19 gem install sinatra
# run rake tasks or tests with that version of ruby:
$ cd someproject
$ ruby19 rake test
$ ruby19 bacon -as
# or, start a new bash shell with the version of ruby so that you
# don't have to prefix each command:
$ ruby19 bash
$ ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.5.0]
# go back to previous shell (and ruby version):
$ exit
# See also:
# multiruby: http://blog.zenspider.com/2007/12/testing-for-ruby-18-and-19-usi.html
# virtualrb: http://github.com/chneukirchen/virtualrb/tree/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment