How to update system Ruby to 1.9.2 on Mac?
I saw an answer saying I should use RVM. But I don't know how even af开发者_StackOverflow中文版ter:
$ rvm system
$ rvm current
system
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
The title of the question, "How to update system Ruby to 1.9.2 on Mac" makes me wonder if you are trying to upgrade Apple's installation of Ruby 1.8.7 to 1.9.2. If that is true, STOP and do NOT try that. The Ruby installed by Apple is for their use, and apps installed by Apple use it.
find /usr -name '*.rb'
will list the reasons why.
RVM and other apps allow you to install Ruby safely, so unless you have very good knowledge of how Unix and the Mac work I strongly recommend you stick to them.
A very common problem we see is that the installation wasn't completed. Read the "Installation" section in the RVM installation page to double-check you've completed everything.
To install Ruby 1.9.2 do:
rvm notes
and read and install the needed dependencies. Then do:
rvm install 1.9.2
rvm use 1.9.2 --default
will tell RVM to always use 1.9.2 as a default. You can switch to the system version installed by Apple using:
rvm use system
and switch back using
rvm default
If you don't want an RVM-based solution:
- Download and install Apple's Xcode developer tools so you get GCC et al, the ability to build your own software. (This is 4.25GB, but you only need to download it once.)
- Download and extract the Ruby Source Code. (10.6MB)
- Open a Terminal window and change into the directory of the source code.
- Run the command
./configure && make
; get a cup of tea while you wait - Run the command
sudo make install
to install this Ruby; you'll need to supply your administrator password - Modify your
PATH
environment variable to put/usr/local/bin
in front of/usr/bin
(so that your new Ruby is found before the system Ruby). You can do this by creating or editing a.profile
file in your home directory to have the line:
export PATH="/usr/local/bin::$PATH"
- If you're running TextMate, you'll also want to go to TextMate ▸ Preferences ▸ Advanced ▸ Shell Variables
and add or edit aPATH
variable like this:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
- If you're running TextMate, you'll also want to go to TextMate ▸ Preferences ▸ Advanced ▸ Shell Variables
After this, rvm use system
will use your 1.9.2p180 (the current version as of this post) install.
I'm assuming you're not sure how to install a new version of ruby with RVM - try:
rvm install 1.9.2
To then make it the default version to use:
rvm use 1.9.2 --default
Consider also: "for OS X try using RailsInstaller for OS X or try the official RVM GUI JewelryBox" -- Quoted from from the 4rd or 5th screen the RVM install page found here http://rvm.io/rvm/install
Whatever you do do not touch or mess with the system default Ruby that ships with your Mac I did that to see what would and my system was out of whack. If you would like to use a different version of Ruby use rvm.
精彩评论