Created
March 6, 2009 01:12
-
-
Save rtomayko/74683 to your computer and use it in GitHub Desktop.
My Multiple Ruby Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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