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

@chino
Copy link

chino commented Jan 31, 2013

I'm not sure if it affects this way of building ruby but to get nice readline support in irb on osx I usually build readline using brew and pass --with-readline-dir http://stackoverflow.com/questions/6970545/make-error-installing-ruby-1-9-2-with-rvm-and-readline-under-osx-lion

@glaszig
Copy link

glaszig commented Feb 9, 2013

can somebody explain to me why everybody wants me to poison my system with the separate command line tool package when, in fact, command line tools (incl. git, compilers and headers) come bundled with xcode inside xcode-select -print-path`/usr/bin` and/or xcode-select -print-path/Toolchains/XcodeDefault.xctoolchain/usr/bin. thank you.

@toioski
Copy link

toioski commented Feb 14, 2013

I can't succeed installing Ruby! I got every time this error:

"Error running 'make', please read /Users/toioski/.rvm/log/ruby-1.9.3-p194/make.log
There has been an error while running make. Halting the installation."

And this is the last part of the log:

"collect2: ld returned 1 exit status
make[2]: *** [../../../.ext/x86_64-darwin12.2.1/digest/md5.bundle] Error 1
make[1]: *** [ext/digest/md5/all] Error 2
make: *** [build-ext] Error 2"

I'm struggling with this installation! I even followed many guides on StackOverFlow but I can't succeed!

Someone can help me? Thanks!

UPDATE: I finally found the solution on StackOverFlow! Just run this command:

"sudo rm /usr/local/lib/libz.* "

This is the official topic: http://stackoverflow.com/questions/5426892/trouble-installing-ruby-1-9-2-with-rvm-mac-os-x

@windix
Copy link

windix commented Feb 15, 2013

before use --with-openssl-dir=$rvm_path/usr, you may need to install openssl first

rvm pkg install openssl

@YayC
Copy link

YayC commented Feb 17, 2013

Thanks so much, very helpful all around.

After installing X Quartz and Open SSL, this did work for me:

rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr

detail of the commands that worked for me:

rvm update
rvm pkg install openssl 

Then I installed x11 from: http://xquartz.macosforge.org/

sudo port selfupdate

Which returned "The ports tree has been updated. To upgrade your installed ports, you should run port upgrade outdated", which I didn't do

sudo port install apple-gcc42

The above took forever to build on my macbook pro

rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
rvm use 1.9.3

@alanjohnson
Copy link

You are awesome sir. this was a big help in getting ree installed. Thanks!

@nlnimis
Copy link

nlnimis commented Mar 4, 2013

this is very helpful. thanks a lot! :)

@tbhockey
Copy link

tbhockey commented Mar 6, 2013

Very helpful, thank you.

@daniambrosio
Copy link

Txs!!! Very helpful!

@nicolasbui
Copy link

I've starts with thoses commands to get things work properly.

brew tap homebrew/dupes
brew install bash curl git
brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba
\curl -L https://get.rvm.io | bash -s stable

@jonalter
Copy link

Thank you!

@fatuhoku
Copy link

+1 for @nicolasbui's 4-liner. Simple and effective.

@jocke
Copy link

jocke commented Apr 4, 2013

Thanks!

Copy link

ghost commented Apr 5, 2013

Thnx, very helpfull and clear!

@misterfitz
Copy link

Cheers, this was very helpful.

@ramhoj
Copy link

ramhoj commented Apr 19, 2013

Thank you!

(My path to gcc was: /usr/local/bin/gcc-4.2 but worked just as fine). Anyone had problems with 1.8.7-p72 receiving the error: "Error running 'make -j8'". Thanks again!

@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