Installing Ruby 1.9.2 on your Mac
I’m assuming you’re using bash, though personally I’m using fish.
If you are already using Homebrew (brew), I would recommend using
Homebrew’s Ruby directly, because it’s simpler. But if you feel
more comfortable with RVM (rvm), it’s ok to use RVM, too. And if
you’re not using Homebrew, than it might be easier that just use RVM.
Here’s the commands to setup everything with Homebrew’s Ruby:
brew update # make sure brew is updated brew install ruby # install ruby 1.9.2 # setup PATH for where gem binaries (executable) are installed. echo 'export PATH=$(brew --prefix ruby)/bin:$PATH' >> ~/.bash_profile gem update --system # update rubygems update_rubygems # sometimes you'll need this to get fully updated. gem install bundler # install latest bundler (you shouldn't use sudo)
Actually, personally I have this line in my ~/.gemrc:
gem: --user --no-ri --no-rdoc
So that my gem binaries are installed to
$(brew --prefix ruby)/bin. Please setup
and either way, you won’t need sudo before installing any gems.
To use the original Ruby which is built-in Mac, use
ruby. If you need to run gem binaries, for example,
bundle, then you’ll need to run it with
/usr/bin/ruby -S bundle.
rake test, I think either one should work:
/usr/bin/ruby -S rake test
But, since Rails 2’s
script/console was very badly written which
irb somewhere in its code, so you can’t really run it
with different ruby without some hack. (!!)
Many people are recommending RVM, indeed it’s good if you really need
multiple versions of Ruby installed. But if you just need one or two
rubies, in my opinion, using RVM makes things a bit more complicated.
Personally, I don’t use RVM, too, since it’s not working correctly
in fish last time I tried. Here’s how I’ll configure RVM:
curl https://rvm.beginrescueend.com/install/rvm | bash # install RVM source ~/.bash_profile # reload PATH for rvm rvm install 1.9.2 # install ruby 1.9.2 rvm --default use 1.9.2 # setup default ruby to 1.9.2 gem update --system # update rubygems update_rubygems # sometimes you'll need this to get fully updated. gem install bundler # install latest bundler (you shouldn't use sudo)
To use the original Ruby which is built-in Mac, use:
rvm use system
Then it would pretend that as if RVM were never installed. Since RVM is
really doing some sandboxes stuffs, so if you really need intensively
test the programs under many different rubies, for example, more than
3 or even 4 versions of rubies (1.8.6, 1.8.7, 1.9.1, 1.9.2, trunk, etc),
it would be a lot easier to just go with RVM. Otherwise, I would prefer
vanilla version (official version without any patches).