I have put together a process that will make Ruby 1.9 from source, and install the resulting binaries in the folder of your choice. The script downloads all the files and patches to /tmp. I also wrote a script that allows me to swap ruby 1.8 and 1.9 as I need.
Here's how I installed the newer version of Ruby in its own directory. First, I downloaded, compiled, and installed readline and patch:
$ cd /tmp
$ curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
$ tar xzvf readline-5.2.tar.gz
$ cd readline-5.2
$ curl -O http://ftp.gnu.org/gnu/readline/readline-5.2-patches/readline52-012
$ patch -p0 <>
$ ./configure --prefix=$HOME/
$ make
$ sudo make install
$ cd ..
Next, I downloaded, compiled, and installed the latest version of Ruby, picking up right where the above commands left off (comments denoted with #):
$ rm index.ht*
$ wget -F ftp://ftp.ruby-lang.org/pub/ruby/1.9/
# I am only interesting in the tar.gz files
# you can go crazy and do a less/more cryptic regex here.
$ sed -e 's#<[^>]*>##g' index.html |sed -e 's#.*File *##g'|sed -e '1,6d'|sed 'N;$!P;$!D;$d'| sed -e '/zip/d'|sed -e '/bz2/d'
$ echo -n "please enter a file from the above list:"
$ read -e Ruby_File
$ curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.9/$Ruby_File
$ tar xzvf {$Ruby_File}
# since we are working in /tmp, I assumed there are no
# existing directories with namme ruby.....
$ cd ruby*
$ autoconf
$ sudo ./configure --prefix=$HOME/ruby--with-readline-dir=$HOME/
$ sudo make
$ sudo make installThe following script allows me to swap default Ruby versions. Instead of changing the path, I rebuild the links every time. I should mention that rake in my system is in /usr/bin, and I had to adjust my script to take care of that.
#!/usr/bin/env bash
rbv=$(ruby -v)
rv=${rbv:5:3}
function r18 () {
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/erb /usr/bin/erb
ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem /usr/bin/gem
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/irb /usr/bin/irb
ln -s /usr/bin/rake.1.8 /usr/bin/rake
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rdoc /usr/bin/rdoc
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ri /usr/bin/ri
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/testrb /usr/bin/testrb
}
function r19 () {
ln -s /Users/luis/ruby1.9/bin/erb /usr/bin/erb
ln -s /Users/luis/ruby1.9/bin/gem /usr/bin/gem
ln -s /Users/luis/ruby1.9/bin/irb /usr/bin/irb
ln -s /Users/luis/ruby1.9/bin/rake /usr/bin/rake
ln -s /Users/luis/ruby1.9/bin/rdoc /usr/bin/rdoc
ln -s /Users/luis/ruby1.9/bin/ri /usr/bin/ri
ln -s /Users/luis/ruby1.9/bin/ruby /usr/bin/ruby
ln -s /Users/luis/ruby1.9/bin/testrb /usr/bin/testrb
}
function cleanruby () {
rm /usr/bin/erb
rm /usr/bin/gem
rm /usr/bin/irb
rm /usr/bin/rake
rm /usr/bin/rdoc
rm /usr/bin/ri
rm /usr/bin/ruby
rm /usr/bin/testrb
}
if [ ${rv} = 1.8 ]; then
echo "Current version is 1.8 swaping to 1.9"
cleanruby
r19
elif [ ${rv} = 1.9 ]; then
echo "Current version is 1.9 swapping to 1.8"
cleanruby
r18
fi
exitMac OS X Hints
http://hints.macworld.com/article.php?story=20090731080242407