Tuesday, February 12, 2013

Ruby 1.9.3 on OSX Mountain Lion with Mac Ports and RVM

I the latest generation of Macbook Pro for most of my development and testing. A good way to work with Ruby is a requirement for my daily tasks. I usually use RVM to manage everything. After a fresh install of OSX I kept getting stopped doing an install of 1.9.3. The errors are mostly related to integer conversion or linking. After several days of pulling teeth, running debuggers,  and read script code I finally have a working Ruby install. For reference my exact steps are:

1. Clean install of OSX.
2. Apply all current updates (bringing my system to 10.8.2)
3. Install Xcode (version 4.6) and command line tools
4. Install MacPorts (2.1.3 10.8)
5. sudo port selfupdate -v
6. sudo port upgrade outdated
7. sudo port install apple-gcc42
8. sudo port install gmake
9. sudo port install gpatch
10. sudo port install binutils
11. sudo ln -s /opt/local/bin/gcc-apple-4.2 /opt/local/bin/gcc
12. sudo ln -s /opt/local/bin/gmake /opt/local/bin/make
13. sudo ln -s /opt/local/bin/gpatch /opt/local/bin/patch
14. sudo port install curl
15. curl -L https://get.rvm.io | bash -s stable
16. Add "source ~/.profile" to top of .bash_profile
17. Reboot ("Reopen windows after reboot" is unchecked)
18. rvm install 1.9.3 in Terminal
And I got:
Davids-MacBook-Pro:~ dmaynor$ rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-1.9.3-p385.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Fetching yaml-0.1.4.tar.gz to /Users/dmaynor/.rvm/archives
######################################################################## 100.0%
Extracting yaml to /Users/dmaynor/.rvm/src/yaml-0.1.4
Configuring yaml in /Users/dmaynor/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/dmaynor/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/dmaynor/.rvm/usr
Installing Ruby from source to: /Users/dmaynor/.rvm/rubies/ruby-1.9.3-p385, this may take a while depending on your cpu(s)...
ruby-1.9.3-p385 - #downloading ruby-1.9.3-p385, this may take a while depending on your connection...
######################################################################## 100.0%
ruby-1.9.3-p385 - #extracting ruby-1.9.3-p385 to /Users/dmaynor/.rvm/src/ruby-1.9.3-p385
ruby-1.9.3-p385 - #extracted to /Users/dmaynor/.rvm/src/ruby-1.9.3-p385
ruby-1.9.3-p385 - #configuring
ruby-1.9.3-p385 - #compiling
ruby-1.9.3-p385 - #installing
Retrieving rubygems-1.8.25
######################################################################## 100.0%
Extracting rubygems-1.8.25 ...
Removing old Rubygems files...
Installing rubygems-1.8.25 for ruby-1.9.3-p385 ...
Installation of rubygems completed successfully.
Saving wrappers to '/Users/dmaynor/.rvm/bin'.
ruby-1.9.3-p385 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p385 - #importing default gemsets, this may take time ...
Install of ruby-1.9.3-p385 - #complete

Davids-MacBook-Pro:~ dmaynor$

I am not saying all of these steps are required, its just what I found to work. Why Mountain Lion ships with ancient versions of tools like Ruby and curl is beyond me. I left out a few steps from the clean install to the current running version but they were cosmetic changes (Terminal coloring), a Firefox install, and a TextMate install that didn't have any impact on the Ruby installation.



3 comments:

Duane Adam said...

I just got my MacBook Pro. And was installing Ruby myself, ran into some troubles myself but finally got it to work (I guess). If only you posted this earlier... aww. Anyways, good post man.

Steven Black said...

This. A hundred times this.

Anonymous said...

Thank you so much. I was tearing my hair out.