Skip to content

Instantly share code, notes, and snippets.

@zenkay
Created August 2, 2012 15:19
Show Gist options
  • Save zenkay/3237860 to your computer and use it in GitHub Desktop.
Save zenkay/3237860 to your computer and use it in GitHub Desktop.
Installation tips for RVM/Ruby on OSX 10.8 Mountain Lion

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

@built
Copy link

built commented Apr 24, 2013

I had an error about autoreconf missing. brew install automake solved that. Also have same path as @ramhoj, so CC=/usr/local/bin/gcc-4.2 rvm install ruby-1.9.3-p194 --enable-shared --without-tk --without-tcl

Thanks for this helpful doc!!

@aubricus
Copy link

Sir. You deserve my thanks. Thanks!

@shaqsnake
Copy link

THX! very helpful!!!

@jplew
Copy link

jplew commented Jul 28, 2013

I was getting a ton of these errors:

Error: C compiler cannot create executables

My problem was that rvm was outdated. After doing this your instructions worked fine:

rvm get latest

Thanks a lot for the guide.

@sjohnson
Copy link

Thank you. I was unable to fix my RVM Ruby installations after moving to Mountain Lion until seeing this. I ended up removing everything ('rvm implode' and removing homebrew) and then following this after reinstalling homebrew and RVM.

The only snag I experienced was figuring out how to change the reference for the C compiler, since I was using homebrew instead of MacPorts.

Here is the error:
You requested building with '/opt/local/bin/gcc-apple-4.2' but it is not in your path.

If you see that error and are using homebrew, you will want to update the command using '/usr/local/bin/gcc-4.2' (as ramhoj mentioned). For example: CC=/usr/local/bin/gcc-4.2 rvm install ruby-1.9.3-p194 --enable-shared --without-tk --without-tcl

I also did an 'rvm get head' before running the above command, and used the generic 'ruby-1.9.3', instead of the more specific 'ruby-1.9.3-p194' and that worked for me.

Thanks again.

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