开发者

OS X 10.6 Installing Nokogiri

I am very new to OS X and I don't know anything about compiling, MacPorts, Homebrew, etc. All I want to do is install the Nokogiri gem on OS X.

In Windows, it was as simple as:

gem install nokogiri

However, when I try this on OS X, I get the following message:

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/ext/nokogiri/gem_make.out

Again, I am not very good with OS X and I have no idea what this means.

Is there an easy way to install Nokogiri without having to mess with MacPorts and other programs I've read about online?

I have XCode 4 installed (some people say XCode is required for this to work), and I'm using Ruby 1.8.7.

Also, I tried installing MacPorts and following the instructions online and I get the following:

Derek-MacBook-Pro:~ derek$ s开发者_开发百科udo port install libxml2 libxslt
Password:
--->  Computing dependencies for libxml2Error: Unable to execute port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
To report a bug, see <http://guide.macports.org/#project.tickets>


I figured out that I needed to install UNIX dev. tools from XCode, which I previously hadn't done. Now the MacPorts command I listed in my question works, and once I successfully got libxml2 installed, I didn't have a problem with the command: sudo gem install nokogiri.


I have a Macbook with Leopard, and I gave up on using MacPorts with Rails some time ago. The pain of getting MacPorts to play along with Ruby, gems, etc., yikes. I switched to RVM (Ruby Version Manager), which allows for installing multiple versions of Ruby and gems, so that you can run one app on one version of Ruby plus some versions of gems, and a different app on different versions of ruby and gems.

It's as simple as rvm install 1.9.2.

Also, I run FreeBSD on my production machine. When I run RVM, I can keep the same versions of gems running on my Macbook, as are running on my production machine by installing RVM on my production machine the same way I have it on my Macbook.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜