How to Switch to Ruby 1.9.3 Installed Using Homebrew

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

Installing Ruby 1.9.3 on Mac

To install a Ruby version with RVM

$ rvm install 1.9.3

then to switch to it

$ rvm use 1.9.3

The latter command is probably the one you forgot to execute.

You might want to configure an .rvmrc file for your project in order to remember the settings.

About the other issue, you should open a separate question.

Installing Ruby with Homebrew

in ~/.bash_profile add the following line

export PATH=/usr/local/Cellar/ruby/1.9.3-p194/bin:$PATH

When you're done, close your terminal and re-open it. You should be fine.

Alternatively, you can execute the follwing in each open shell instead of closing/re-opening:

source ~/.bash_profile

Note:
I highly recommend installing ruby via rvm or rbenv so you can manage multiple ruby versions and use gemsets.

Trying to install ruby 1.9.3

As discussed in chat, this seemed to fix it:

rvm install ruby-1.9.3 --with-gcc=`which gcc`

Trying to install ruby 1.9.3 with rbenv

You do need to include $PATH in each of those lines in your .bash_profile otherwise you'll lose the default paths (including /bin, which is where bash is installed by default on OS X).

As this stands, without $PATH on the second line of your .bash_profile, you're completely overwriting your previous path with "/usr/local/bin:subli". Then the third line adds "$HOME/.rbenv/bin" in addition to that, but you're still going to be missing things like /bin, /usr/bin, etc.

I would go ahead and make sure that you are including $PATH in all three of those lines so that you add to, rather than replace, your existing path.

Is it possible to install Ruby 1.9.3-p327 on OS X Mavericks? And if so, how?

If it's not neccesary to use rvm to install this version of ruby, you can use rbenv. I just installed this exactly version without any problems. And it's easy to install it with brew.

If it won't work, then the problem in another place.

Installation of ruby 1.9.3 in Mac OS Mavericks

I used @UnholySheep advice and resolved my problem.

First I found that gcc46 were installed:

$ gcc-4.6 -v
Using built-in specs.
COLLECT_GCC=gcc-4.6
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc46/4.6.4/libexec/gcc/x86_64-apple-darwin13.0.0/4.6.4/lto-wrapper
Target: x86_64-apple-darwin13.0.0
Configured with: ../configure --build=x86_64-apple-darwin13.0.0 --prefix=/usr/local/Cellar/gcc46/4.6.4 --enable-languages=c --program-suffix=-4.6 --with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08 --with-ppl=/usr/local/opt/ppl011 --with-cloog=/usr/local/opt/cloog-ppl015 --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 4.6.4 (GCC)

I used locate gcc-4.6 and found that homebrew installed it under /usr/local/bin. Then created a symlink as suggested by @UnholySheep:

sudo ln -s /usr/local/bin/gcc-4.6 /bin/gcc-4.6


Related Topics



Leave a reply



Submit