How do I install Ruby on Mac Leopard?
Can anyone please give directions on how to install ruby 1.9 I tried installation directions given all over the web. Can't get it to work. Please k开发者_如何学编程indly give step by step direction. I tried using macports but everytime I type in ruby -v it gives me 1.8.6.
rvm is easiest way to manage your ruby installation on OSX.
If you are using rvm, you will able to install 1.9.1, 1.9.2, jruby, ree by typing rvm install 1.9.1
type rvm default
to reset your ruby version back to 1.8.6
How to install rvm
sudo gem install rvm -s http://gemcutter.org/
rvm-install
rvm install 1.9.1
rvm use 1.9.1
ruby -v # show ruby 1.9.1 version
rvm default
ruby -v # show ruby 1.8.6 version
cheers
Install Homebrew.
brew install ruby
installs the current stable version of ruby.
Use Ruby Version Manager. It will allow you to install most versions of Ruby and help you manage gems across them.
Ok this is how I remember doing it
- Install Macports
- Type
sudo port install ruby19
- Make sure that
/opt/local/bin
is in your path. If not add it. - Now to use ruby1.9 you type
ruby1.9 example.rb
Also additionally if you dont want to use ruby
command to use the default version. You can create a simple symlink in which make the ruby at /usr/bin/ruby
point to /opt/local/bin/ruby1.9
.
That way your ruby version will be 1.9. However I dont recommend doing that. As there are certain gems, that might not work with 1.9, which might be affected
Not sure if you ever solved this. But it sounds like 1 of 2 problems:
1. You installed the wrong ruby with MacPorts
if you just ran port install ruby
, then you installed the old version, which explains why ruby -v
still shows 1.8.6.
If you ran port install ruby19
, then you installed ruby 1.9, but under the name ruby19. To access it, you'd have to type ruby19
in place of ruby
...so ruby19 script/generate
, ruby19 -v
...etc.
To fix that you can do port install ruby19+nosuffix
2. you still have your PATH set to the old Ruby, which is why you're getting 1.8.6 on ruby -v
.
First you gotta figure out where OSX is looking for your ruby by typing which ruby
. If you're using MacPorts, that command should return /opt/local/bin/ruby
. If which ruby
returns /usr/bin/ruby
, then it's still finding the default ruby that comes with OSX, which is 1.8.6.
To change your PATH, go open up .bash_profile, located in your user folder (if you have textmate, you can do mate
~/.bash_profile). Add in this line and save:
echo PATH="/opt/local/bin:/opt/bin:$PATH"
Basically you add the MacPorts ruby into your PATH, so the system looks for ruby in the /opt
folder too. Also, maybe more importantly, you put the MacPorts path in front of the default PATH, so it will find that one first.
Goodluck with that. Personally though, I vote for Homebrew. You can find my setup for that at my blog.
On my MacBook Pro I just did a good old compile and install. Download the 1.9.1 source from the Ruby web site (www.ruby-lang.org) and then compile. It'll install to /usr/local/bin so you will not corrupt the 1.8 if you wanted to revert back.
I never used the ports myself, but I know a lot that have/do. http://hivelogic.com/articles/ruby-rails-leopard is a good online guide for people not familiar with compiling and installing from source code.
Just had to do this on a factory-fresh Mac last night, and it's gotten slightly more complicated recently. GCC is no longer directly supported by Apple, as they prefer Clang, and Xcode 4.3+ requires the command line tools to be installed separately before you can access Clang from the terminal. So here goes!
1.) Install XCode.(it's free!)
2.) Install RVM. Go to a terminal window and enter:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
3a.) If you've installed XCode before 4.3, skip this step. Go to Xcode>Preferences>Downloads tab and install the XCode command Line Tools. This will let you access clang from Terminal.
3.)Open up terminal and enter:
rvm install 1.9.3 --with-gcc=clang
this will install ruby 1.9.3 in OSX
You can use the one-click-installer :
http://rubyosx.rubyforge.org/
- Install MacPorts
- Type
port install ruby19
精彩评论