Managing my Ruby versions with rbenv
UPDATE 1 Warning: Ruby has issues with Clang. If you don’t have the gcc compiler because you have only XCode 4.2 installed without 4.1, than as of today (november 8th 2011) no version of Ruby pass the tests.
UPDATE 2 (25 Feb 2012) From now on, I do not compile my rubies anymore with CLANG. I finally installed GCC.
I have decided to move away from rvm and give rbenv a try. ruby-build makes it easy to install ruby versions ala rvm install. But it doesn’t work for me now since I have upgraded to XCode 4.2 and gcc has been replaced with the LLVM project. Some are installing gcc back so they can continue to use their tools which rely on good old gcc. If you don’t do it, you will to tweak compiler option with this when you compile:
--with-gcc=clang
The following show you how I compiled and manage my Ruby versions.
- Install XCode 4.2 from the App Store (free)
- Follow rbenv installation
Clone the Ruby repository which will be used to compile all wanted versions
$ git clone git://github.com/ruby/ruby.git
$ cd ruby
Checking all tagged version that can be checked out and compiled
$ git tag
Installing Ruby 1.9.2
$ git checkout v1_9_2_290
Creating a directory with the Ruby 1.9.2 source
$ git checkout-index -af --prefix=../ruby_v1.9.2p290/
$ cd ../ruby_v1.9.2p290
Generate the configure script
$ autoconf
Compile and install
$ ./configure --with-gcc=clang --prefix=$HOME/.rbenv/versions/1.9.2-p290
$ make
$ make install
Make 1.9.2 your default Ruby version
$ rbenv versions
1.9.2-p290
$ rbenv global 1.9.2-p290
Activating Ruby 1.9.2
$ rbenv shell 1.9.2p2
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32478) [x86_64-darwin11.2.0]
Installing Ruby 1.8.7
$ cd ruby
$ git checkout v1_8_7_352
$ git checkout-index -af --prefix=../ruby_v1.8.7p352/
$ cd ../ruby_v1.8.7p352
$ ./configure --with-gcc=clang --prefix=$HOME/.rbenv/versions/1.8.7-p352
$ make
$ make install
Activating Ruby 1.8.7
$ rbenv shell 1.8.7-p352
$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]