Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install Ruby 1.9.3 in Mac OS X Mountain Lion without Xcode?

I would like to know about alternative ways to build a development machine for Ruby 1.9.3 on OS X 10.8 Mountain Lion, that does not require Xcode.

Mountain Lion is now Golden Master as I'm writing this question, so it could be considered as final version. That cannot be said about Xcode, that is a preview release yet.

RVM recommends to install osx-gcc-installer over Xcode, but I would like not to mess my system.

What is the cleanest way to install Ruby 1.9.3 on Mountain Lion without Xcode?

like image 976
David Morales Avatar asked Jul 11 '12 15:07

David Morales


People also ask

How do I install Mountain Lion on my Mac?

Reinstalling Mountain LionClick Reinstall OS X, and then Continue. Follow the instructions on the screen, and then choose your hard disk. Click Install, and enter your Apple ID information if prompted. When the installation is complete, select App Store... from the Apple menu, and install any available updates.

Does macOS come with Ruby?

MacOS comes with a "system Ruby" pre-installed. If you see /usr/bin/ruby , it is the pre-installed macOS system Ruby. It's fine to use the system Ruby for running sysadmin scripts, as long as you don't alter the system Ruby by attempting to update it or add gems.


2 Answers

osx-gcc-installer turns out to be a very good option to replace Xcode in order to install Ruby 1.9.3

These are the steps I have followed:

  1. Download & install the latest version of osx-gcc-installer here (GCC-10.7-v2 is fine): https://github.com/kennethreitz/osx-gcc-installer
  2. Install RVM as usual and select 1.9.3-head as the default ruby installation: https://rvm.io/rvm/install/
  3. Install Homebrew: https://github.com/mxcl/homebrew/wiki/installation
  4. Install libksba to resolve some dependencies with Ruby 1.9.3: brew install libksba

That's it! You should now have Ruby 1.9.3 installed on Mountain Lion working perfectly.

If you need some other packages, install them now through Homebrew, such as Imagemagick for example: brew install imagemagick

It's possible that you need XQuartz for Homebrew to work properly, as Apple is not shipping X11 since Mountain Lion. You can download it here: http://xquartz.macosforge.org/trac/wiki

EDIT:

Now (since 29th July) Command line tools for Xcode 4.4 are available.

So, the new steps are these:

  1. Download & install Command line tools for Xcode 4.4 (you don't need to download Xcode): https://developer.apple.com/downloads/index.action
  2. Install Homebrew: https://github.com/mxcl/homebrew/wiki/installation
  3. Install automake: brew install automake
  4. Install RVM as usual and select 1.9.3-head as the default ruby installation: https://rvm.io/rvm/install/

Optional step: You may need XQuartz for some components, for example for Imagemagick, so download & install XQuartz: http://xquartz.macosforge.org/trac/wiki

like image 181
David Morales Avatar answered Sep 30 '22 01:09

David Morales


I also had to add this:

export CC=/usr/bin/gcc-4.2

in order to make the Apple command line tools work with the rvm. Without this I had repeated llvm issues:

The provided CC(gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.

like image 34
fuzzygroup Avatar answered Sep 30 '22 02:09

fuzzygroup