Create ruby ​​1.9 by default on os x

How to make ruby ​​1.9 the default version instead of 1.8.x, which is set to os x by default?

Thanks.

+7
ruby operating-system macos
source share
5 answers

Starting with version 2.1.3, the β€œcorrect” MacPorts way of installing a specific package version is to use the select command as the default, for example:

sudo port select --set ruby ruby19

There seems to be no documentation on this command in the MacPorts manual . However, you can run port help select to get a very limited description. This function replaces the +nosuffix "option" style to set the default version.

+6
source share

I recommend installing the RVM tool from http://rvm.beginrescueend.com/ (it has installation instructions

It allows you to have multiple versions of ruby ​​and gemstones. After installing RVM, install the required Ruby 1.9 using:

 rvm install ruby-1.9.1 

To make it default:

 rvm --default ruby-1.9.1 

After that, it will be the default ruby.

+4
source share

RVM is great for setting up multiple environments with different versions of Ruby and gems.

If you, however, want to have Ruby 1.9, you can simply install it using MacPort. It will take precedence over the already installed default in OS X.

  • Download MacPort if you haven’t already. This is the Mac package manager.
  • In terminal use MacPort to install Ruby 1.9 and RubyGems
    sudo port selfupdate
    sudo port install ruby19
    sudo port install rb-rubygems

You should have Ruby 1.9 installed and ahead of the way. Do ruby -v to check. Use Ruby gems to install any other Ruby components, such as Rails.

Ports are installed in the / opt / local / bin directory, and MacPort updates the PATH environment variable so that it is matched before the pre-installed / usr / bin packages.

+3
source share

you could create an alias, not a symbolic link ... that way, both versions remain untouched. add the following line to .profile in the user's home folder (create if does not exist):

 alias ruby='/opt/local/bin/ruby1.9' 

then enter the file:

 source .profile 

hope that helps :)

+3
source share

I would say skip rvm.

In my case, MacPorts did preend / opt / local / bin in my path, but installed ruby ​​1.9 as ruby1.9. (Ruby Care β†’ / usr / bin / ruby.)

To date, the easiest way to fix:

 sudo su cd /opt/local/bin ln -s ruby1.9 ruby 

Poof. Done.

Exact teams:

 nsmcs-macbook-pro:~ nsmc$ which ruby /usr/bin/ruby nsmcs-macbook-pro:~ nsmc$ echo $PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin nsmcs-macbook-pro:~ nsmc$ which ruby1.9 /opt/local/bin/ruby1.9 nsmcs-macbook-pro:~ nsmc$ sudo su Password: sh-3.2# cd /opt/local/bin/ sh-3.2# ls -l ruby* -rwxr-xr-x 2 root admin 9040 Feb 16 07:43 ruby1.9 sh-3.2# ln -s ruby1.9 ruby sh-3.2# which ruby /opt/local/bin/ruby sh-3.2# ruby --version ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10] 
+2
source share

All Articles