Nokogiri gem无法在OS X Mavericks中安装

时间:2022-11-09 00:15:43

Install fails showing:

安装失败显示:

checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
libiconv is missing.

However, looking at nokogiri's mkmf.log, the following errors are shown:

但是,查看nokogiri的mkmf.log,会显示以下错误:

ld: warning: ignoring file /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib

ld: warning: ignoring file /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib

ld: warning: ignoring file /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib

I have xcode and it's command tools installed. My ~/.bash_profile has 64bit compiling forced by: export ARCHFLAGS="-arch x86_64"

我有xcode和它的命令工具安装。我的〜/ .bash_profile有64位编译强制执行:export ARCHFLAGS =“ - arch x86_64”

I have libxml2, libxslt, and libiconv installed via Homebrew, and each is linked. I've tried installing all of these without the ARCHFLAG in .bash_profile.

我通过Homebrew安装了libxml2,libxslt和libiconv,每个都是链接的。我已经尝试在没有ARCHFLAG的情况下安装所有这些.bash_profile。

I've also brew install apple-gcc42 and linked, as per how tos I've found.

我已经按照我发现的方式酿造安装apple-gcc42并进行链接。

I've tried installing nokogiri by passing paths to libxml2, libxslt, and libiconv in /usr/local/Cellar/, but the install still fails, with same errors as above.

我已尝试通过将路径传递到/ usr / local / Cellar /中的libxml2,libxslt和libiconv来安装nokogiri,但安装仍然失败,并出现与上述相同的错误。

I've wasted at least a day on this - just trying to get one Ruby gem installed. I'd really like to get back to actually developing.

我浪费了至少一天的时间 - 只是试图安装一个Ruby gem。我真的想回到实际开发阶段。

Can anyone please help?

有人可以帮忙吗?

5 个解决方案

#1


21  

Setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before actually installing the gem did the trick for me.

在实际安装gem之前设置NOKOGIRI_USE_SYSTEM_LIBRARIES = 1对我来说是个窍门。

Summarising:

  • If previously installed, uninstall the gem:
    $ gem uninstall nokogiri

    如果以前安装过,请卸载gem:$ gem uninstall nokogiri

  • Use Homebrew to install libxml2, libxslt and libiconv if needed:
    $ brew install libxml2 libxslt libiconv

    如果需要,使用Homebrew安装libxml2,libxslt和libiconv:$ brew install libxml2 libxslt libiconv

  • Install the gem specifying the paths to the libraries to be linked against:
    $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

    安装gem指定要链接的库的路径:$ NOKOGIRI_USE_SYSTEM_LIBRARIES = 1 gem install nokogiri - --use-system-libraries --with-iconv-dir =“$(brew --prefix libiconv)” - with-xml2-config =“$(brew --prefix libxml2)/ bin / xml2-config”--with-xslt-config =“$(brew --prefix libxslt)/ bin / xslt-config”

#2


2  

  • As a self-contained solution, I've put together this ruby script as a gist that should work with any recent Mac OS X / Homebrew installation.
  • 作为一个独立的解决方案,我将这个ruby脚本放在一起,作为一个应该与最近的Mac OS X / Homebrew安装一起使用的要点。

  • You're basically just on on relying Homebrew's libraries instead of the outdated Apple ones. Simple.
  • 你基本上只是依靠Homebrew的库而不是过时的Apple库。简单。

  • You can configure and install with Bundler (instead of gem) by passing bundle as an argument.
  • 您可以通过传递bundle作为参数来配置和安装Bundler(而不是gem)。

Check it out, and please feel free to contribute--maybe we can boil this down to one script to fix them all!

检查一下,请随时提供帮助 - 也许我们可以将其归结为一个脚本来解决所有问题!

#3


0  

  • Check if HomeBrew is installed correctly with the appropriate XCode command line tools.
  • 使用相应的XCode命令行工具检查HomeBrew是否已正确安装。

brew doctor

  • You can also check via XCode > Preferences
  • 您也可以通过XCode>首选项进行检查

With valid command line tools installed, I was able to resolve the nokogiri error encountered after the OSX Maverick upgrade.

通过安装有效的命令行工具,我能够解决OSX Maverick升级后遇到的nokogiri错误。

Also found that some of the 'brew' packages were outdated after the OS X Mountain Lion to Maverick upgrade. (e.g. qt, postgresql)

还发现一些'brew'软件包在OS X Mountain Lion到Maverick升级之后已经过时了。 (例如qt,postgresql)

#4


0  

Here's what worked for me:

这对我有用:

  1. If you haven't already done so, install the XCode developer tools: $ xcode-select --install
  2. 如果您还没有这样做,请安装XCode开发人员工具:$ xcode-select --install

  3. Use homebrew to install (or reinstall) libxml2, libxslt and libiconv: $ brew install libxml2 libxslt libiconv
  4. 使用homebrew安装(或重新安装)libxml2,libxslt和libiconv:$ brew install libxml2 libxslt libiconv

  5. Install nokogiri: gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv
  6. 安装nokogiri:gem install nokogiri - --with-iconv-dir = / usr / local / opt / libiconv

I found the solution I needed in an unmerged pull request to update the Nokogiri tutorials. I recommend that if someone else encounters this issue and has exhausted the solutions here, check that pull request list to see if someone has submitted an update to the instructions on the Nokogiri tutorials page.

我在未合并的拉取请求中找到了我需要的解决方案来更新Nokogiri教程。我建议如果其他人遇到此问题并且已经用尽了解决方案,请检查拉取请求列表以查看是否有人提交了Nokogiri教程页面上的说明更新。

#5


0  

From github page First, you should: xcode-select --install and then re-install nokogiri. That worked for me while another suggestion didn't. Hope this helps someone else.

从github页面首先,您应该:xcode-select --install然后重新安装nokogiri。这对我有用,而另一个建议却没有。希望这有助于其他人。

#1


21  

Setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before actually installing the gem did the trick for me.

在实际安装gem之前设置NOKOGIRI_USE_SYSTEM_LIBRARIES = 1对我来说是个窍门。

Summarising:

  • If previously installed, uninstall the gem:
    $ gem uninstall nokogiri

    如果以前安装过,请卸载gem:$ gem uninstall nokogiri

  • Use Homebrew to install libxml2, libxslt and libiconv if needed:
    $ brew install libxml2 libxslt libiconv

    如果需要,使用Homebrew安装libxml2,libxslt和libiconv:$ brew install libxml2 libxslt libiconv

  • Install the gem specifying the paths to the libraries to be linked against:
    $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

    安装gem指定要链接的库的路径:$ NOKOGIRI_USE_SYSTEM_LIBRARIES = 1 gem install nokogiri - --use-system-libraries --with-iconv-dir =“$(brew --prefix libiconv)” - with-xml2-config =“$(brew --prefix libxml2)/ bin / xml2-config”--with-xslt-config =“$(brew --prefix libxslt)/ bin / xslt-config”

#2


2  

  • As a self-contained solution, I've put together this ruby script as a gist that should work with any recent Mac OS X / Homebrew installation.
  • 作为一个独立的解决方案,我将这个ruby脚本放在一起,作为一个应该与最近的Mac OS X / Homebrew安装一起使用的要点。

  • You're basically just on on relying Homebrew's libraries instead of the outdated Apple ones. Simple.
  • 你基本上只是依靠Homebrew的库而不是过时的Apple库。简单。

  • You can configure and install with Bundler (instead of gem) by passing bundle as an argument.
  • 您可以通过传递bundle作为参数来配置和安装Bundler(而不是gem)。

Check it out, and please feel free to contribute--maybe we can boil this down to one script to fix them all!

检查一下,请随时提供帮助 - 也许我们可以将其归结为一个脚本来解决所有问题!

#3


0  

  • Check if HomeBrew is installed correctly with the appropriate XCode command line tools.
  • 使用相应的XCode命令行工具检查HomeBrew是否已正确安装。

brew doctor

  • You can also check via XCode > Preferences
  • 您也可以通过XCode>首选项进行检查

With valid command line tools installed, I was able to resolve the nokogiri error encountered after the OSX Maverick upgrade.

通过安装有效的命令行工具,我能够解决OSX Maverick升级后遇到的nokogiri错误。

Also found that some of the 'brew' packages were outdated after the OS X Mountain Lion to Maverick upgrade. (e.g. qt, postgresql)

还发现一些'brew'软件包在OS X Mountain Lion到Maverick升级之后已经过时了。 (例如qt,postgresql)

#4


0  

Here's what worked for me:

这对我有用:

  1. If you haven't already done so, install the XCode developer tools: $ xcode-select --install
  2. 如果您还没有这样做,请安装XCode开发人员工具:$ xcode-select --install

  3. Use homebrew to install (or reinstall) libxml2, libxslt and libiconv: $ brew install libxml2 libxslt libiconv
  4. 使用homebrew安装(或重新安装)libxml2,libxslt和libiconv:$ brew install libxml2 libxslt libiconv

  5. Install nokogiri: gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv
  6. 安装nokogiri:gem install nokogiri - --with-iconv-dir = / usr / local / opt / libiconv

I found the solution I needed in an unmerged pull request to update the Nokogiri tutorials. I recommend that if someone else encounters this issue and has exhausted the solutions here, check that pull request list to see if someone has submitted an update to the instructions on the Nokogiri tutorials page.

我在未合并的拉取请求中找到了我需要的解决方案来更新Nokogiri教程。我建议如果其他人遇到此问题并且已经用尽了解决方案,请检查拉取请求列表以查看是否有人提交了Nokogiri教程页面上的说明更新。

#5


0  

From github page First, you should: xcode-select --install and then re-install nokogiri. That worked for me while another suggestion didn't. Hope this helps someone else.

从github页面首先,您应该:xcode-select --install然后重新安装nokogiri。这对我有用,而另一个建议却没有。希望这有助于其他人。