Install Ruby with rbenv
I decided to setup Octopress on my Mac so that I can publish blog posts from either Windows or MacOS. I’m on OS X 10.8.2.
I tried to follow the Octopress instructions for installing Ruby but ran into a few problems.
Homebrew is a package manager for OS X. Open Terminal and install Homebrew with:
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Once the installation is successful, you can run the following command to check your environment.
$ brew doctor
Apparently, you should see:
Your system is raring to brew
But instead I had 3 warnings.
Warning: /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew. The following tools exist at both paths: gcov-4.2 Consider amending your PATH so that /usr/local/bin occurs before /usr/bin in your PATH.
This one can be fixed by modifying your
.profile file. Create it if it doesn’t already exist. Use
nano ~/.profile if you don’t have a preferred editor.
1 2 3
Google tells me the other two warnings are related to Mono being installed and can be ignored.
Warning: /Library/Frameworks/Mono.framework detected This can be picked up by CMake's build system and likely cause the build to fail. You may need to move this file out of the way to compile CMake. Warning: You have a non-Homebrew 'pkg-config' in your PATH: /usr/bin/pkg-config => /Library/Frameworks/Mono.framework/Versions/2.10.9/bin/pkg-config This was most likely created by the Mono installer. `./configure` may have problems finding brew-installed packages using this other pkg-config.
Rbenv handles the installation of multiple Ruby environments.
$ brew update $ brew install rbenv $ brew install ruby-build
If I try to install Ruby immediately, I get
ERROR: This package must be compiled with GCC, but ruby-build couldn't find a suitable `gcc` executable on your system. Please install GCC and try again. ...
XCode used to ship with a compatible gcc, but no longer does. We can install it with Homebrew.
$ brew update $ brew tap homebrew/dupes $ brew install autoconf automake apple-gcc42
The new gcc will coexist happily alongside the default one.
Install Ruby 1.9.3
Now we can install Ruby.
$ rbenv install 1.9.3-p194 $ rbenv rehash
$ ruby --version
Hmm… I get
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
Shouldn’t it say ruby 1.9.3? It turns out you need to add the following to the end of your
Now quit and restart Terminal.
$ rbenv global 1.9.3-p194 $ ruby --version ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.1]
Ruby 1.9.3 is installed correctly. If I quit and restart Terminal,
ruby --version is still 1.9.3.