Hello, I’m a web craftsman with a passion for the modern web. I build web applications and play with social services and communities.
February 25, 2012 at 5:17 pm
Since Xcode 4.2 Apple doesn’t ship a normal GCC anymore, but instead packages LLVM. While it was possible to compile Ruby with LLVM before, the result was error prone. Not anymore! Since 1.9.3-p125 Ruby is fully compatible with LLVM and here is how you can install it without the need of any additional GCC installation.
I’m going to use rbenv and ruby-build in the progress. This way everything is installed in ~/.rbenv and you won’t need any administrator privileges.
- Install Xcode 4.3 or the new stand-alone command line tools
- Install rbenv and ruby-build
# install rbenv $ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile $ echo 'eval "$(rbenv init -)"' >> .bash_profile # You may be using Zsh or any other shell. # I presume you know how to adopt the previous two lines then. # install ruby-build $ mkdir -p ~/.rbenv/plugins $ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # reload bash (alternatively close and re-open Terminal) $ source ~/.bash_profile
- Compile Ruby 1.9.3-p125 and make default ruby
$ env CC=/usr/bin/gcc rbenv install 1.9.3-p125 $ rbenv global 1.9.3-p125 $ rbenv rehash
- Done. Check everything is ok now
$ ruby -v # => ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
Sweet. Leave a note in the comments if this helped you. Happy coding!
4 Responses to “How to install Ruby 1.9.3 on Mac OS X with LLVM and rbenv”
Leave a Reply
Thanks a lot Matthias, your post put me on the right track!
(BTW the labels for your comment fields seem to be shifted down)
Thanks a lot, you save my lot of times.
Sure wish I understood what any of these steps was actually doing. What if I don’t want to install it to be default, for example?
Thanks dude! It was useful!