【问题标题】:OS X 10.6 Installing NokogiriOS X 10.6 安装 Nokogiri
【发布时间】:2011-03-31 19:13:58
【问题描述】:

我是 OS X 的新手,我对编译、MacPorts、Homebrew 等一无所知。我想做的就是在 OS X 上安装 Nokogiri gem。

在 Windows 中,它很简单:

gem install nokogiri

但是,当我在 OS X 上尝试此操作时,我收到以下消息:

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

再说一次,我对 OS X 不是很好,我不知道这意味着什么。

有没有一种简单的方法来安装 Nokogiri,而不必弄乱我在网上读到的 MacPorts 和其他程序?

我安装了 XCode 4(有人说需要 XCode 才能工作),我使用的是 Ruby 1.8.7。

另外,我尝试安装 MacPorts 并按照在线说明进行操作,结果如下:

Derek-MacBook-Pro:~ derek$ sudo 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>

【问题讨论】:

    标签: ruby rubygems nokogiri


    【解决方案1】:

    我发现我需要安装 UNIX dev。 XCode 的工具,我以前没有做过。现在我在我的问题中列出的 MacPorts 命令有效,一旦我成功安装了 libxml2,我对命令没有任何问题:sudo gem install nokogiri

    【讨论】:

    • 让您的 XCode 保持最新状态非常重要。 Snow Leopard DVD 上的版本已损坏。从 Apple 的 XCode 站点下载当前的 XCode,如果它是新的,请安装它。这是一个大文件,所以下载需要一段时间。
    【解决方案2】:

    我有一台装有 Leopard 的 Macbook,不久前我放弃了使用带有 Rails 的 MacPorts。让 MacPorts 与 Ruby、gem 等一起玩的痛苦,哎呀。我切换到 RVM(Ruby 版本管理器),它允许安装多个版本的 Ruby 和 gems,这样您就可以在一个 Ruby 版本和一些版本的 gems 上运行一个应用程序,并在不同版本的 ruby​​ 和 gems 上运行不同的应用程序.

    就像rvm install 1.9.2一样简单。

    另外,我在生产机器上运行 FreeBSD。当我运行 RVM 时,我可以在我的 Macbook 上运行与在我的生产机器上运行相同版本的 gem,方法是在我的生产机器上安装 RVM,就像在我的 Macbook 上一样。

    【讨论】:

      猜你喜欢
      • 2011-07-29
      • 2014-01-01
      • 1970-01-01
      • 2011-03-20
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多