Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Notes on using ruby 1.9 and 1.8 side by side (tested on OS X 10.5 and 10.6), plus a small script to toggle between 1.9 and 1.8 ruby installations
mkdir -p ~/src
SetFile -a "V" ~/src
cd ~/src
curl -O ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.9.1-p243.tar.gz
tar xzvf ruby-1.9.1-p243.tar.gz
cd ruby-1.9.1-p243/
autoconf
./configure --program-suffix=19 --enable-shared --with-readline-dir=/usr/local --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make && sudo make install
cd ..
# Ruby gems is included with 1.9, so no need to install it here
# but, we do need to update it...
sudo gem19 update --system
sudo gem19 install gem-sane-binary
curl -O ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.7-p174.tar.gz
tar xzvf ruby-1.8.7-p174.tar.gz
cd ruby-1.8.7-p174/
autoconf
./configure --program-suffix=18 --enable-shared --with-readline-dir=/usr/local --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make && sudo make install
cd ..
curl -L -O http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar xzvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo /usr/local/bin/ruby18 setup.rb
cd ..
sudo gem18 install gem-sane-binary
# now we can use toggle.rb (I install it as ~/sbin/trb)
#!/usr/bin/env ruby
v = RUBY_VERSION.match(/^1\.9/) ? "18" : "19"
%w{ruby irb gem erb ri rdoc}.each do |c|
system "sudo ln -fs /usr/local/bin/#{c+v} /usr/local/bin/#{c}"
end
system "ruby --version"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment