开发者

Upgrading Ruby on Mac OS X

I am reading the book Programming Ruby and am looking to upgrade the version of Ruby on my computer. I run Mac OS X Snow Leopard and doing ruby -v in the command line shows I am running Ruby 1.8.7.

I installed MacPorts an开发者_如何学Pythond ran the sudo port install ruby19 command but whenever I type ruby -v, it still shows Ruby 1.8.7.

Could anyone help with this? Thank you.


The tool "rvm" is pretty good. It stands for Ruby Verson Manager I think, and the developer is good at support in the irc channels. You can install multiple versions of ruby along side each other pick the ones you want to use.

http://rvm.io


You have to use ruby19 to run ruby if you installed it that way. You can also use irb19, and ri19.


I updated the link to RVM in one of the answers, but also a quick poll of some friends doing Ruby dev currently revealed a preference for rbenv as a ruby environment manager: http://github.com/sstephenson/rbenv/


As mentioned in hvgotcodes answer, RVM seems to be a great way of handling this.

I recently started learning Ruby (and Rails) myself, and this[1] tutorial has a great section on using RVM. I'd highly recommend you give it a go, it's especially handy so that you can follow different tutorials on different versions of Ruby if you wish.

[1] http://railstutorial.org/book#sec:rubygems


As @Andrew Grimm eluded, the problem you are having is likely due to a problem in your $PATH variable. Since macports typically installs stuff in /opt, modifying your $PATH variable to:

$ export PATH=/opt/local/bin:$PATH

Will most likely help. However, I would urge you to look into RVM as @hvgotcodes recommends.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜