RSS-feed

Sat, 06 Sep 2008

Working with ruby 1.9 and 1.8 (from trunk)


I want to start playing with 1.9 but I want to keep 1.8 around. And also, I want to have the *latest* version of each branch. This is what I came up with:

$ pwd
/Users/drio/ruby
$ svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby
$ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8
$ cd ruby
$ autoconf && ./configure --prefix=/Users/drio/local/ruby1.9 && make -j8 && make install
$ cd ../ruby_1_8
$ autoconf && ./configure --prefix=/Users/drio/local/ruby1.8 && make -j8 && make install
// add /Users/drio/local/ruby_local/bin to your path (change your user name of course)

Now, use this bash function:

funtion rversion() {
  r_local="$HOME/local/ruby_local"
  rm -rf $r_local && mkdir $r_local && cd $r_local

  case "$1" in
    '8')
      version="ruby1.8"
      l_dirs="bin lib share"
      ;;
    '9')
      version="ruby1.9"
      l_dirs="bin include lib share"
      ;;
    *)
      echo "8 or 9 ?"
      ;;
  esac

  for d in $l_dirs
  do
    echo "linking $version/$d"
    ln -s ../$version/$d .
  done
  cd - > /dev/null
}

Load that function and now, from the shell:

drio@lupita:~ $ rversion 8
linking ruby1.8/bin
linking ruby1.8/lib
linking ruby1.8/share
drio@lupita:~ $ ruby --version
ruby 1.8.7 (2008-09-03 revision 19079) [i386-darwin9.4.0]
drio@lupita:~ $ rversion 9
linking ruby1.9/bin
linking ruby1.9/include
linking ruby1.9/lib
linking ruby1.9/share
drio@lupita:~ $ ruby --version
ruby 1.9.0 (2008-09-07 revision 19210) [i386-darwin9.4.0]


posted at: 23:54 | path: /ruby | permanent link to this entry