Skip to content

Instantly share code, notes, and snippets.

@pedrolopez
Forked from zenkay/gist:3237860
Created June 11, 2014 19:56
Show Gist options
  • Save pedrolopez/3fc221f538fb4a3c5bc6 to your computer and use it in GitHub Desktop.
Save pedrolopez/3fc221f538fb4a3c5bc6 to your computer and use it in GitHub Desktop.

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

Install Compilers and CLI Tools

Mountain Lion supports only XCode 4.4 or greater. Basic 4.4 installer doesn't install Unix's standard command line tools by default. You have to install it using separate package (from Apple Developer's) or directly from XCode 4.4 preference panel (Preferences : Downloads : Components : Install).

When installation is complete, tools are finally available but is not enough. Unfortunately llvm_gcc-4.2 compiler ship with XCode is not suitable to compile Ruby (it works but some features are buggy).

You have to install the stand-alone gcc package. You can use:

Macports:

sudo port selfupdate
sudo port install apple-gcc42

Homebrew:

brew update
brew tap homebrew/dupes
brew install apple-gcc42

Now you have Unix's standard command line tools (and stuff like git and svn come back to work) and a stand-alone version of gcc-4.2.

Install Ruby: the right way

Now it's time to compile your Ruby version using one of the following commands (latest version of last major releases):

Ruby 1.8.7

CC=/opt/local/bin/gcc-apple-4.2 rvm install ruby-1.8.7-p370 --enable-shared --without-tk --without-tcl

Ruby 1.9.2

CC=/opt/local/bin/gcc-apple-4.2 rvm install ruby-1.9.2-p320 --enable-shared --without-tk --without-tcl

Ruby 1.9.3

CC=/opt/local/bin/gcc-apple-4.2 rvm install ruby-1.9.3-p194 --enable-shared --without-tk --without-tcl

If some of these version are already installed you have to run rvm remove followed by the ruby version or use rvm reinstall command instead rvm install.

CC=/opt/local/bin/gcc-apple-4.2 force installer to use stand-alone version of gcc (I use the MacPorts one, /opt/local/bin/ is standard MacPorts path).

--without-tk --without-tcl options disable Tcl/Tk libraries that require X11 (i didn't try to compile without these options and connect XQuartz).

Install Ruby Enterprise Edition: the right way

REE installer require a working C++ compiler but can't recognize the g++ command because looks for g++-4.2. You can fix this bug creating a symbolic link to g++

ln -s /usr/bin/g++ /usr/bin/g++-4.2

Then you can run following command like the other releases

CC=/opt/local/bin/gcc-apple-4.2 rvm install ree-1.8.7-2012.02 --enable-shared --without-tk --without-tcl``

Extras

Install X.Org

X11 is not required in order to install Ruby but if you use stuff like ImageMagick (and rmagic) you need it.

The easier way to have X11 on OSX 10.8 is to use XQuartz (http://xquartz.macosforge.org) available in a comfortable .dmg

OpenSSL

When you try to connect to a secure server using https standard library you get the following error:

Errno::ECONNRESET Connection reset by peer - SSL_connect

The problem seems to be related to OpenSSL version 1.0.1.

I can't find a solution that works for me yet but some people was able to fix it using the following option when they compile Ruby: --with-openssl-dir=$rvm_path/usr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment