How to Update Ruby to 1.9.X on Mac

How to update Ruby to 1.9.x on Mac?

I'll make a strong suggestion for rvm.

It's a great way to manage multiple Rubies and gems sets without colliding with the system version.


I'll add that now (4/2/2013), I use rbenv a lot, because my needs are simple. RVM is great, but it's got a lot of capability I never need, so I have it on some machines and rbenv on my desktop and laptop. It's worth checking out both and seeing which works best for your needs.

Best way to update Ruby to the latest 1.9 version on OS X?

Most people use RVM to install Ruby on the mac. Basically it allows you to have multiple versions of ruby installed on the same machine and to switch between them at will. You can also install gems on a project by project basis rather than installing them all globally using sudo like you probably do now.

You can install RVM by running

bash < <(curl -s https://rvm.ioinstall/rvm)

in terminal (assuming you have git installed). Full installation instructions can be found on the RVM site.

Here is a tutorial which I personally found invaluable when getting used to using RVM in my workflow at the start. It will probably help you too.

Can I upgrade to the current version of Ruby (2.2.3) on OS X v10.6.8?

I suggest that you use RVM to install Ruby.

curl -sSL https://get.rvm.io | bash -s stable --ruby

You need to restart the terminal in order to run rvm:

rvm install 2.2
rvm use 2.2 --default

How can I switch to ruby 1.9.3 installed using Homebrew?

I suggest you take a look at rvm.
You can then set it as default with rvm use 1.9.3 --default

But if you are happy with your homebrew install.

Then just change the precedence of directories in the PATH

Here is my /etc/paths

# homebrews should always take precedence
/usr/local/bin

# the default stack
/usr/bin
/bin
/usr/sbin
/sbin

This is important generally for homebrew, else the system version of git, ruby, pg_admin,... will all be used instead of the brew version.

if you say which -a ruby you'll see all the installed rubies, and the precedence in the PATH

eg.

$ which -a ruby
/Users/matthew/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
/Users/matthew/.rvm/bin/ruby
/usr/bin/ruby


UPDATE: I now don't think you should change /etc/paths

Instead you need to check which of .profile, .bashrc, or .bash_login is being loaded in your shell, and just add /usr/local/bin to your path.

For me, I only have a .profile. You can create that file if none of those files already exist in your home directory.

# homebrews should always take precedence
export PATH=/usr/local/bin:$PATH

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

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

Trouble Installing Ruby 1.9.3 on Mac OSX 10.9.4

Error: No available formula for gcc46

Try:

rvm install 1.9.3 --with-gcc=clang

Or install xcode:

xcode-select --install


Related Topics



Leave a reply



Submit