开发者

Can't install Ruby on OS X

I'm trying to follow the installation instructions for Ruby on Rails from Hivelogic.com. I've done this before on previous开发者_开发技巧 installs of OSX without trouble. I'm having trouble this time installing on Snow Leopard.

At the end of the "make" step installing Ruby, I get a number of errors related to readline. Not sure if this matters, but here they are:

readline.c: In function ‘username_completion_proc_call’:
readline.c:730: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:730: error: (Each undeclared identifier is reported only once
readline.c:730: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1

When I try to sudo make install, I get more errors. When I "which ruby", I get /usr/local/bin/ruby which is correct. But as soon as I try to use ruby, I get this message: "You need the Rosetta software to run ruby. The Rosetta installer is in Optional Installs on your Mac OS X installation disc." That's weird, but I installed Rosetta, and was able to proceed.

Except: I still have Ruby1.8.6 installed (not 1.8.7). "ruby -v" reports 1.8.6. 1.8.6 was the version that was migrated (I assume) from the Leopard install on this machine. In other words: where's my new Ruby? How do I get 1.8.7 (required by the current version of Rails) installed correctly?


I've always found macports the best way to install/manage my ruby versions. I have 1.8.6, 1.8.7 and 1.9.1 all installed using macports.

First, grab macports and install it.

Then, update (or create) your ~/.bashrc file to include the following line:

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

This places all macports executables in front of you path, so you system will find them first.

Finally, install any of the versions of ruby you want:

sudo port install ruby186
sudo port install ruby
sudo port install ruby19

I also recommend installing rubygems from scratch after ruby is installed. Grab the latest rubygems release here and then run the following from inside the downloaded rubygems directory:

sudo ruby setup.rb

Hope this works out for you.


If you have snow leopard than 1.8.7 is pre-installed in /usr/bin


Another option is to use VirtualBox and install Ubuntu on VirtualBox. Ruby installation and usage is much smoother this way I have found, as I wasted a lot of time trying to get Ruby working properly on the Mac.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜