为什么在 Mac OS 上安装 Nokogiri 失败并缺少 libiconv?

发布于 2024-10-29 20:57:31 字数 2992 浏览 6 评论 0原文

我一直在尝试在 Mac OS 10.9.3 上安装 Nokogiri,无论我尝试什么,安装最终都会失败,并显示以下错误消息:

$ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib'
This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build


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

遵循在网上找到的大量帮助后,包括使用brew构建和安装 libxml2 和 libxslt并从源代码构建 libiconv(如“安装 Nokogiri”中所述),错误仍然相同。

当尝试运行 Nokogiri 的安装时,libxml2 和 libxslt 似乎运行良好,但 libiconv 则不然。

对这些事情有更多了解的人知道如何安装 Nokogiri 吗?

I've been trying to install Nokogiri on Mac OS 10.9.3 and whatever I try, the install fails in the end with the following error message:

$ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib'
This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build


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

After following a lot of help found around the web including building and installing libxml2 and libxslt using brew and building libiconv from the sources (as described in "Installing Nokogiri"), the error remains the same.

When trying to run the installation for Nokogiri, libxml2 and libxslt seem to be found fine, but not libiconv.

Anyone with a better knowledge of these things know how to get Nokogiri installed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

一梦等七年七年为一梦 2024-11-05 20:57:32

我在运行 Ruby 2.1.4Yosemite 上解决了这个问题,方法是

  1. 确保安装了 xCode 6.1,然后
  2. xcode-select --install,然后
  3. 在AppStore 点击更新并安装最新版本的命令行工具(显然xcode-select --install 不这样做 - 叹息)
  4. 然后捆绑安装 工作正常。

我也做了一个 brew install libiconv ,但我不相信这一步是必要的。

I solved this on Yosemite running Ruby 2.1.4 by

  1. ensure you have xCode 6.1 installed, then
  2. xcode-select --install, then
  3. In the AppStore click on updates and install the most recent version of the command-line tools (which apparently xcode-select --install does't do - sigh)
  4. then bundle install worked as normal.

I also did a brew install libiconv too but I am not convinced that step was needed.

探春 2024-11-05 20:57:32

我尝试了很多事情,但没有任何对我有用。然后我终于找到了 iconv 文档,它救了我的命!

I tried many things but nothing worked for me. Then I finally found the iconv documentation and it saved my day!

2024-11-05 20:57:32

查看 mkmf 文件,似乎 nokogiri (或 gem,我不知道)尝试在 /op/local/ 中查找依赖项。对我来说,这不是寻找它们的正确路径。

强制 nokogiri 在正确的位置找到库(我使用自制程序)对我来说是成功的:

$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/

也许 nokogiri 中有一些需要修复的东西......

HTH,

Looking in the mkmf file, it apear that nokogiri (or gem, I don't know) try to find dependencies in /op/local/. For me it's not the right path to search them for.

Forcing nokogiri to find the libs at the right place (I use homebrew) did the trick for me :

$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/

Maybe there is something to fix in nokogiri...

HTH,

梦幻之岛 2024-11-05 20:57:32

libiconv 已从 Homebrew 0.9 中删除。现在建议从源代码编译 libiconv,然后在安装 nokogiri gem 时引用安装。请参阅 Nokogiri 安装页面 上 Homebrew 0.9 部分下的 Nokogiri 安装说明

libiconv was removed from Homebrew 0.9 Now it's recommended to compile libiconv from source, then reference the install when you install the nokogiri gem. See the Nokogiri install instructions under the Homebrew 0.9 section on the Nokogiri install page

吃颗糖壮壮胆 2024-11-05 20:57:32

查看gem 构建目录中的mkmf.log 文件(例如/Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/ext/nokogiri/mkmf.log)。那有很多更多的信息。就我而言,当我遇到这个问题时,Nokogiri 专门将 /opt/local/lib 添加到库搜索路径中,并且 GNU Backgammon 在那里安装了不兼容的 libiconv。

Look in the mkmf.log file in the gem's build directory (e.g. /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/ext/nokogiri/mkmf.log). That has a lot more info. In my case when I hit this it was that Nokogiri specifically adds /opt/local/lib to the library search path and GNU Backgammon had installed an incompatible libiconv there.

递刀给你 2024-11-05 20:57:32

假设您使用 MacPorts 安装了 libxml2 和 libxslt,那么由于调用 have_func('iconv_open', 'iconv.h') 所使用的包含路径和链接路径的顺序不匹配,您可能仍然会收到此错误

。 ) 解决方案:删除/usr/local/lib中的libiconv.*

Assuming you installed libxml2 and libxslt with MacPorts, then you might still be getting this error due to a mismatch of the order of include paths and link paths used by the call to have_func('iconv_open', 'iconv.h')

Simple (patch) solution: delete libiconv.* in /usr/local/lib

爱给你人给你 2024-11-05 20:57:32
$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/

与上面相同,这是自制程序和使用 gem install 的解决方案(应用更改取决于您的版本)

但是,如果您使用 Gemfile 和捆绑安装,则应该在安装之前应用捆绑配置,这里再次是代码

$ bundle config build.nokogiri --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/ --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

,应用更改取决于在您的版本上

希望这会对您有所帮助。

信用:https://gist.github.com/1344331

$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/

same as above, this is the solution for homebrew and using gem install (apply changes depends on your version)

however, if you use Gemfile and bundle install, you should apply the bundle config before you install, here the code

$ bundle config build.nokogiri --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/ --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

again, apply changes depends on your version

hope this will help you.

credit: https://gist.github.com/1344331

谜泪 2024-11-05 20:57:32

我在《山狮》上也遇到过类似的麻烦。事实证明,我之前已经通过 rvm 包安装了 libiconv,而对于 ruby​​ 1.9.3/Mountain Lion/nokogiri 来说,这不再是必需的。

按照 https://rvm.io/packages/ 的建议,我删除了 $rvm_path/usr 目录并重建红宝石 1.9.3。此后安装 nokogiri 就是一个简单的 gem 安装。不要搞乱brew/macports/手动源安装!

I had similar trouble on Mountain Lion. Turns out I had installed libiconv via rvm package previously and this is no longer necessary for ruby 1.9.3/Mountain Lion/nokogiri.

Following the advice of https://rvm.io/packages/, I deleted my $rvm_path/usr directory and rebuilt ruby 1.9.3. Thereafter installing nokogiri was a simple gem install. No messing with brew/macports/manual source installs!

唱一曲作罢 2024-11-05 20:57:32

您也可以在 Mavericks 上执行此操作:

gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs /MacOSX10.9.sdk/usr/include/libxml2

只要确保你已经安装了 xcode

You could also do this on Mavericks:

gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2

Just make sure you have xcode installed

但可醉心 2024-11-05 20:57:32

今天我在 OS X 10.10 Yosemite 上与 Nokogiri 战斗了一段时间,

由于某种原因,我的环境被搞乱了。

哪个bundlewhich gem给了我/usr/bin/bundle/usr/bin/gem的 ~/.rbenv/shims/gem

帮助我纠正它的是 sudo rm -i /usr/bin/gem /usr/bin/bundle

之后我:
1.切换回我的项目目录
2.卸载依赖
3.(重新)安装依赖库:进行了 brew install libxml2 libiconv libxslt
4.安装了我的全新 ruby​​ 版本(使用 rbenv)
5.gem 安装了捆绑器
6.并且bundle install运行没有任何问题。

Nokogiri 之后就好了。

供参考:

╰─% cat .bundle/config           
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_JOBS: 4

╰─% which ruby bundle gem
~/.rbenv/shims/ruby
~/.rbenv/shims/bundle
~/.rbenv/shims/gem

I was fighting with Nokogiri for a while today on OS X 10.10 Yosemite

My environment was messed up for some reason.

which bundle and which gem were giving me /usr/bin/bundle and /usr/bin/gem instead of ~/.rbenv/shims/gem

What helped correct it for me was sudo rm -i /usr/bin/gem /usr/bin/bundle

After that I:
1. switched back to my project directory
2. uninstalled the dependent
3. (re)-installed the dependent libs: did a brew install libxml2 libiconv libxslt
4. installed my ruby version fresh (with rbenv)
5. did gem install bundler
6. and bundle install ran without any problems.

Nokogiri was fine after that.

For reference:

╰─% cat .bundle/config           
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_JOBS: 4

╰─% which ruby bundle gem
~/.rbenv/shims/ruby
~/.rbenv/shims/bundle
~/.rbenv/shims/gem
天暗了我发光 2024-11-05 20:57:32

这对我有用

sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.6.2 -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/2.9.3/ --with -iconv-dir=/usr/local/Cellar/libiconv/1.14

This one worked for me

sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.6.2 -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/2.9.3/ --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

夏末染殇 2024-11-05 20:57:32

您需要将自制程序升级到 0.9,

然后按照以下步骤操作

brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

您应该仔细检查文件夹库版本。

You need to upgrade your homebrew to 0.9

then follow these steps

brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

You should double check the folder library version.

水波映月 2024-11-05 20:57:32

自制软件用户

如果您使用自制软件,解决此问题的正确解决方案是:

xcode-select --install

从对话框中选择“获取 Xcode”。

brew unlink libiconv
gem install nokogiri

xcode-select 步骤修复了 Xcode 安装和 Xcode Command Line Utils 安装。我发现由于操作系统升级或从备份恢复出现某种问题,我没有 /usr/include/iconv.h。如果运行 xcode-select 后没有该头文件和 /usr/lib/libconv.dylib 那么您很可能需要将 Xcode 从应用程序文件夹拖到垃圾箱并重新安装,然后手动下载 Xcode 的命令行工具从 https://developer.apple.com/downloads/index.action 并安装那。

然后你需要从自制程序中取消 libiconv 的链接。你不需要这个。 clang 实际上会通过 /usr/include/iconv.h 获取 /usr/local/include/iconv.h ,并将 #define iconv_open 到 libiconv_open 但然后链接到 /usr/lib/libiconv.dylib ,它没有 libiconv_open这就是导致 mkmf 无法找到 libiconv 的原因。您需要做的是删除 iconv.h 中的链接,以便 nokogiri 找不到它。

然后正常构建 nokogiri 即可。

对于新用户,您需要做的就是使用 xcode-select 安装 xcode 并安装 nokogiri,但如果您发现这个问题,那么可能您的安装是错误的,而不是全新安装的 Mavericks。

这里的其他一些答案肯定是不正确的。他们中的大多数人尝试在自制软件中使用 libiconv,这是完全没有必要的。 brew link libiconv 的答案实际上导致了 clang 变得混乱并尝试读取自制头文件并链接到系统库的问题。建议 --use-system-libraries 的答案很差,因为 nokogiri 需要与其捆绑的 libxml2 和 libxslt 库链接,因为这些库的其他版本与其不兼容。想要你从源代码编译的答案实在是太复杂了。

TL;DR:

  • 升级和/或修复您的 Xcode 安装
  • 取消链接您的自制 libiconv,因为尝试使用它只会导致问题
  • 正常构建 nokogiri

RVM 用户

旧的 RVM 安装可能有一个 libiconv 隐藏在您的 rvm 目录中的某处与您的系统库冲突。有关更多信息,请参阅 https://stackoverflow.com/a/11809261/506908

MacPorts 用户

如果您有 /opt/local/lib/libiconv.dylib,那么 nokogiri 会将该路径添加到它搜索的目录列表中,并且它将找到 MacPorts 安装,类似于它如何选择homebrew libiconv 与系统库冲突。您可以尝试:

sudo port uninstall libiconv

如果由于依赖关系而失败,那么您可以尝试直接链接 MacPorts 版本(未经测试):

gem install nokogiri -- --with-iconv-dir=/opt/local

HOMEBREW USERS

Correct solution to fix this problem if you are using homebrew:

xcode-select --install

Choose "Get Xcode" from the dialog box.

brew unlink libiconv
gem install nokogiri

The xcode-select step fixes your Xcode installation and Xcode Command Line Utils installation. I found that I didn't have /usr/include/iconv.h due to some kind of problem with O/S upgrades or restores from backups. If you don't have that header file and /usr/lib/libconv.dylib after running xcode-select then you most likely need to drag Xcode from the Application folder to the trash and reinstall and then manually download the Command Line Tools for Xcode from https://developer.apple.com/downloads/index.action and install that.

Then you need to unlink the libiconv from homebrew. You don't need this. And clang will actually pick up /usr/local/include/iconv.h over /usr/include/iconv.h and will #define iconv_open to libiconv_open but then link against /usr/lib/libiconv.dylib which does not have libiconv_open which is what causes the mkmf failures to find libiconv. What you need to do is remove the linking in of iconv.h so that nokogiri will not find it.

Then just build nokogiri normally.

For new users, all you should need to do is install xcode with xcode-select and install nokogiri, but if you've found this question then presumably you've got a botched installation and not a fresh install of Mavericks.

Some of the other answers here are definitely incorrect. Most of them attempt to use libiconv out of homebrew which is entirely unnecessary. The answers that brew link libiconv are actually causing the problem where clang becomes confused and tries to read a homebrew header file and link against the system libraries. The answers which suggest --use-system-libraries are poor because nokogiri needs to be linked against its bundled libxml2 and libxslt libraries because other versions of those libraries are incompatible with it. The answers which want you to compile from sources are just hopelessly overly complicated.

TL;DR:

  • Upgrade and/or repair your Xcode installation
  • Unlink your homebrew libiconv since trying to use that only causes problems
  • Build nokogiri normally

RVM USERS

Old RVM installations may have a libiconv hiding in your rvm directories somewhere which are conflicting with your system libraries. See https://stackoverflow.com/a/11809261/506908 for more information.

MacPorts USERS

If you have /opt/local/lib/libiconv.dylib then nokogiri adds that path to the list of directories that it searches for and it will find the MacPorts installation similar to how it picks up the homebrew libiconv and conflicts with the system libraries. You can try:

sudo port uninstall libiconv

If that fails due to dependencies then you can try linking against the MacPorts version directly (untested):

gem install nokogiri -- --with-iconv-dir=/opt/local
酷到爆炸 2024-11-05 20:57:32

今天早上,我在升级到小牛队后遇到了这个问题。我们做了很多事情。但是,如果有人遇到此问题,可以尝试以下一些操作。

我运行了“xcode-select --install”,然后安装了命令行工具(令人惊讶的是这没有在操作系统升级上更新)。
我运行了“rvm implode”(稍后我将重新构建它)。

我们拼凑了两个错误输出文件:

~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out

~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext /nokogiri/tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0/configure.log

这似乎表明 c 编译器使用了令人惊讶的设置。

我运行了“env”

输出包含:

...
CXX=/usr/local/opt/apple-gcc42/bin/g++-4.2
...
CC=/usr/local/opt/apple-gcc42/bin/gcc-4.2
...

这些文件在文件系统上不存在...

在所有这些更改移动到新的终端窗口之后(所以一切都是新鲜的)。安装 vagrant-berkshelf (反过来安装 nokogiri)效果很好。

注意:在新窗口中运行“env”时,不再有 CC 或 CXX 的设置...

不确定其中的关键部分,或者顺序是否重要,但尝试重新创建似乎在其中发挥作用的部分让这个发挥作用。

I ran into this, this morning... after an upgrade to Mavericks. We did many things. However if anyone is having this issue here are some things to try.

I ran 'xcode-select --install' then got the command line tools installed (surprised this didn't update on the OS ugrade).
I ran 'rvm implode' (I will build it back up later).

We pieced together two error output files:

~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out

~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0/configure.log

Which seemed to indicate that the c compiler was using a surprising setting.

I ran 'env'

Output contained:

...
CXX=/usr/local/opt/apple-gcc42/bin/g++-4.2
...
CC=/usr/local/opt/apple-gcc42/bin/gcc-4.2
...

These files didn't exist on the file system...

After all of these changes moving to a new terminal windows (so everything was fresh). Installation of vagrant-berkshelf (which in turn installs nokogiri) worked fine.

NOTE: when running 'env' in the fresh window there was no longer a setting for CC or CXX...

Unsure on the key part of this, or if order matters, but tried to recreate the parts that seemed to play a role in getting this to work.

风向决定发型 2024-11-05 20:57:32

根据文档,从 OSX 10.9 和 Homebrew 9.5+ 开始,您可能缺少开发工具。

Nokogiri 安装

疑难解答

如果您遇到提及 libiconv 缺失的问题,如下所示:

Installing nokogiri (1.6.2.1) Building nokogiri using packaged libraries.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for          help with installing dependencies.
-----
*** extconf.rb failed ***

那么您就是可能缺少正确的开发工具。这是一个非常简单的修复:

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

已在 OSX 10.9 w/ xcode 的 clang 编译器上验证了这一点。

According to the documentation, as of OSX 10.9 and Homebrew 9.5+, you are probably missing the development tools.

Nokogiri installation

Troubleshooting

If you have problems mentioning libiconv missing that looks something like this:

Installing nokogiri (1.6.2.1) Building nokogiri using packaged libraries.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for          help with installing dependencies.
-----
*** extconf.rb failed ***

Then you are probably missing the right developer tools. This is a really easy fix:

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

This is verified working on OSX 10.9 w/ xcode’s clang compiler.

小傻瓜 2024-11-05 20:57:32

当我将 Mac 操作系统升级到 Yosemite 时,我遇到了这个问题。我能够通过执行以下操作来解决这个问题:

xcode-select --install
brew uninstall libiconv
brew install libiconv
gem install nokogiri

I got this issue when I upgraded my Mac OS to Yosemite. I was able to solve this issue by doing:

xcode-select --install
brew uninstall libiconv
brew install libiconv
gem install nokogiri
旧伤还要旧人安 2024-11-05 20:57:32

我遇到了类似的问题,并且接受的答案曾经对我有用。但是现在,我看到了一条新的错误消息,其中缺少 gmkdir 命令,如以下问题所示:

gem install nokogiri -v '1.5.11'由于 make 失败:/usr/local/bin/gmkdir:没有这样的文件或目录

对我有用的是首先进行一些清理:

brew uninstall libiconv
brew uninstall libxml2
brew uninstall libxslt

然后 brew unlink libiconv 以及您需要的任何其他内容取消链接(使用 brew doctor 检查)。然后,神奇的两行(从链接的答案复制):

brew install coreutils
gem install nokogiri

I had a similar issue and the accepted answer used to work for me. Now, however I have been seeing a new error message where a gmkdir command is missing as in this question:

gem install nokogiri -v '1.5.11' failed due to make: /usr/local/bin/gmkdir: No such file or directory

What worked for me was first a little cleanup:

brew uninstall libiconv
brew uninstall libxml2
brew uninstall libxslt

And then brew unlink libiconv and whatever else you need to unlink (check with brew doctor). Then, the magic two lines (copied from the linked answer):

brew install coreutils
gem install nokogiri
夏夜暖风 2024-11-05 20:57:32

在开始卸载和安装任何内容之前,请遵循简单的步骤。
检查您是否安装了 CLT(安装了命令行工具):

brew config

请在此处查看 CLT 版本,如果已安装,则无需重新安装。

这意味着问题出在您仅重新安装捆绑器 gem 使其不具有 sudo 的权限。
卸载捆绑程序
gem 卸载捆绑程序
重新安装 gem 捆绑程序
gem install bundler

这里最重要的一点是安装捆绑程序 gem 的权限,它永远不应该被 sudoed。

Simple steps to follow before you start uninstalling and installing anything.
Check if you have CLT (command line tools installed):

brew config

see the CLT version here if its installed no need for reinstallation.

This means the issue is with permission you have reinstall only bundler gem make its not sudo.
Uninstall bundler with
gem uninstall bundler
reinstall gem bundler
gem install bundler

Most important point here is the permission under which bundler gem is installed it should never be sudoed.

合久必婚 2024-11-05 20:57:32

首先,请确保遵循 nokogiri 上的安装指南:http://nokogiri.org/tutorials/installing_nokogiri。 html

按照指南进行操作后,我仍然遇到这个问题。这就是我解决它的方法:

首先我使用自制程序安装了 iconv:
然后我卸载

了 ruby​​,幸运的是,这对于 rvm 来说非常容易:

rvm uninstall 1.9.2        

然后我必须使用以下选项重新安装 ruby​​:

CC=gcc-4.2 rvm install 1.9.2-p290 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1

然后我使用新的 ruby​​ 版本创建一个 gemset:

rvm use 1.9.2@coolproject

然后我终于可以像这样安装 nokogiri:

gem install nokogiri -v=1.4.4 -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

First of all make sure you follow the installation guide on nokogiri: http://nokogiri.org/tutorials/installing_nokogiri.html

After having followed the guide I still had this issue. This is how I solved it:

First of all I installed iconv using homebrew:
brew install iconv

Then I uninstalled ruby, luckily this is very easy with rvm:

rvm uninstall 1.9.2        

Then I had to reinstall ruby with the following options:

CC=gcc-4.2 rvm install 1.9.2-p290 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1

Then I create a gemset with the new ruby version:

rvm use 1.9.2@coolproject

Then I can finally install nokogiri like this:

gem install nokogiri -v=1.4.4 -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
疯了 2024-11-05 20:57:32

就我而言,(与 scotchi 一样)构建失败是因为 /opt/local/lib 中存在不兼容的 iconv 库。
默认情况下,Nokogiri 构建过程首先查看 /opt/local。
要强制它使用不同的安装目录(例如 /usr/local),请执行以下操作:

gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xslt-lib=/usr/local/lib --with-xslt-include=/usr/local/include

In my case, (as with scotchi) the build failed because of an incompatible iconv library in /opt/local/lib.
By default, theNokogiri build process looks at /opt/local first.
To force it to use a different install directory, /usr/local for example, do:

gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xslt-lib=/usr/local/lib --with-xslt-include=/usr/local/include
凌乱心跳 2024-11-05 20:57:32

这篇博客文章建议手动安装libiconv。

随后,可以使用许多开关来安装 nokogiri,告诉它在哪里可以找到 libiconv(请参阅博客文章)。

附带说明:安装 nokogiri 后,我成功安装了 gollum(安装也失败了,因为找不到 iconv)。现在我仍然面临问题,因为当我启动 gollum 时,Python 崩溃了。

This blog post proposes to install libiconv manually.

Subsequently, nokogiri can be installed with a number of switches telling it where to find libiconv (see the blog post).

As a side note: After installing nokogiri, I managed to install gollum (installation of which also failed because it could not find iconv). Now I am still facing problems though, because when I start up gollum, Python crashes.

听风吹 2024-11-05 20:57:32
$ gem install iconv # works but it is missing an iconv.so file in ruby 2.0.0-p247

$ ls -1 2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/iconv.so*

$ ls -1 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*

注意 2.0.0-p247 中缺少 /lib/iconv/iconv.so 文件,该文件存在于 2.0.0-p0 gems 安装中。

$ rbenv version
2.0.0-p247 (set by /home/XXX/tmp/.ruby-version)
$ rbenv which gem
/home/XXX/.rbenv/versions/2.0.0-p247/bin/gem
$ gem --version
1.8.25

$ rbenv which pry
/home/XXX/.rbenv/versions/2.0.0-p247/bin/pry
$ pry
[1] pry(main)> require 'iconv'
LoadError: cannot load such file -- iconv/iconv.so
from /home/XXX/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'

复制文件,

$ pushd ~/.rbenv/versions/
$ cp 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/

现在可以了!

$ pry
[1] pry(main)> require 'iconv'
=> true
$ gem install iconv # works but it is missing an iconv.so file in ruby 2.0.0-p247

$ ls -1 2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/iconv.so*

$ ls -1 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*

NOTE THE MISSING /lib/iconv/iconv.so file in 2.0.0-p247 that is present in 2.0.0-p0 gems installation.

$ rbenv version
2.0.0-p247 (set by /home/XXX/tmp/.ruby-version)
$ rbenv which gem
/home/XXX/.rbenv/versions/2.0.0-p247/bin/gem
$ gem --version
1.8.25

$ rbenv which pry
/home/XXX/.rbenv/versions/2.0.0-p247/bin/pry
$ pry
[1] pry(main)> require 'iconv'
LoadError: cannot load such file -- iconv/iconv.so
from /home/XXX/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'

Copy the file over

$ pushd ~/.rbenv/versions/
$ cp 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/

NOW IT WORKS!

$ pry
[1] pry(main)> require 'iconv'
=> true
风流物 2024-11-05 20:57:32

在运行 ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1 之前,我必须先安装 gcc

I had to install gcc first before running ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1

-小熊_ 2024-11-05 20:57:31

我有同样的问题。不幸的是,“安装 Nokogiri” 并没有涵盖 Iconv 问题。这是我解决问题的方法。

首先安装homebrew,它会让你的生活更轻松。如果您已经安装了它,请务必通过更新来获取最新的公式,如下所示:

brew update

注意:在 OSX 10.9+ 中,您可能需要安装 xCode 命令工具才能安装 libiconv。

xcode-select --install

然后安装较新版本的 libiconv

brew install libiconv

然后安装你的 gem

gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

I had the same issue. Unfortunately the "Installing Nokogiri" doesn't cover Iconv issues. Here's how I resolved the issue.

First install homebrew, it'll make your life easier. If you already have it installed, be sure to grab the latest formulae by updating like so:

brew update

Note: In OSX 10.9+ you may need to install xCode command tools to allow you to install libiconv.

xcode-select --install

then install a newer version of libiconv

brew install libiconv

then install your gem

gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
脸赞 2024-11-05 20:57:31

尝试使用系统库。 OSX 在较新版本中附带了 libiconv,但默认安装脚本似乎有问题

gem install nokogiri -- --use-system-libraries

编辑: 如果使用捆绑器,如 Geoff 你可以这样做:

bundle config build.nokogiri --use-system-libraries

Try using the system libraries. OSX comes with libiconv in newer versions, but the defaults install script seems to have a problem

gem install nokogiri -- --use-system-libraries

Edit: If using bundler, as mentioned by Geoff you can do:

bundle config build.nokogiri --use-system-libraries
貪欢 2024-11-05 20:57:31

@Cory 的解决方案包含正确的答案,但 Mavericks 上的解决方案实际上比顶级解决方案简单得多,因此我仅使用必要的步骤重新发布。

在 Mavericks (OSX 10.9+) 上:

安装 Xcode 命令行工具:

xcode-select --install

然后安装 gem:

gem install nokogiri

@Cory's solution contains the correct answer, but the solution on Mavericks is actually much simpler than the top solution so I'm reposting with only the necessary steps.

On Mavericks (OSX 10.9+):

Install Xcode Command Line Tools:

xcode-select --install

then install your gem:

gem install nokogiri
怎会甘心 2024-11-05 20:57:31

我终于能够解决这个问题了。上述解决方案都没有为我完全修复它。

我在 OSX Lion 10.7.2 上尝试 gem install nokogiri 时收到此错误。首先,这个错误掩盖了真正的问题,说 libiconv 丢失,因为即使 nokogiri 找不到 libxslt 或 libxml2,你也会得到同样的错误,而在我的例子中,它找不到。

因此,我按照 Homebrew 部分下的 http://nokogiri.org/tutorials/installing_nokogiri.html 上的说明进行操作(稍作修改考虑到 libxml2 的最新版本):

brew install libxml2
brew link libxml2

# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
make
sudo make install

此时,我按照 nokogiri 站点上的说明进行了尝试,

gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

但是,这仍然失败,因为从源代码构建 libxslt 时,它会将 /include 文件夹安装在一个时髦的地方。因此,您需要分别指定 libinclude 文件夹,如下所示:

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt

这仍然不起作用(相同的 libiconv 错误),所以我尝试指定所有三个必需的库( libxslt、libxml2 和 libiconv):

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8

现在我遇到了不同的错误!这仍然是一个错误,但至少有所不同。制作过程失败:

in /opt/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64

呃,什么?经过大量谷歌搜索后,我发现了这个奇迹帖子: http://www.refresherate.com/2010/01/08/fixing-ld-warning-in-usrlocalliblibz-dylib-file-is-not-of-required-architecture/ 显然,

OSX Lion 附带了一些错误版本的 libz 库(libz.dylib、libz.1.dylib、libz.1.2.4.dylib),并且需要将它们替换为Xcode SDK 的最新版本。这篇文章比我解释得更好,因此请阅读上面的链接以获取具体说明。

更换这些后,我

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8

再次跑步,一切都很好。我希望这对其他人有帮助。

I was finally able to solve this problem. None of the above solutions completely fixed it for me.

I was getting this error when trying to gem install nokogiri on OSX Lion 10.7.2. First of all, this error masks the real problem by saying libiconv is missing, because you will get the same error even if nokogiri can't find libxslt or libxml2, which in my case, it couldn't.

So I followed the instructions on http://nokogiri.org/tutorials/installing_nokogiri.html under the Homebrew section (slightly modified to account for a more current version of libxml2):

brew install libxml2
brew link libxml2

# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
make
sudo make install

At this point I followed the directions on the nokogiri site and tried

gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

However, this still failed because when building libxslt from source, it installs the /include folder in a funky place. So you need to specify the lib and include folders separately like so:

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt

This still didn't work (same libiconv error), so I tried to specify all three required libraries (libxslt, libxml2 and libiconv):

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8

Now I got a different error! It was still an error but at least it was different. The make process failed with:

in /opt/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64

Uhh, what? After a lot of googling, I came across this miracle post: http://www.refresherate.com/2010/01/08/fixing-ld-warning-in-usrlocalliblibz-dylib-file-is-not-of-required-architecture/

Apparently OSX Lion ships with some bad versions of the libz library (libz.dylib, libz.1.dylib, libz.1.2.4.dylib) and and they need to be replaced with the latest versions from the Xcode SDK. The article explains it better than I can so read the above link for specific instructions.

Once these were replaced, I ran

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8

again and all was well. I hope this helps someone else.

ㄟ。诗瑗 2024-11-05 20:57:31

只是向人群添加我的声音,但 mkmf.log 说了一些关于无法找到 x86_64 架构的符号的信息。我偶然发现了这个解决方案:

sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries

可能无法为原始提问者解决任何问题,但这可能会对某人有所帮助。

旁注:nokogiri 是我使用 ruby​​ 应用程序的最大障碍。每当有人依赖不同的版本时,我就必须弄清楚如何构建它。而且我的问题每次都不一样。

Just adding my voice to the crowd, but mkmf.log said something about not being able to find symbols for x86_64 architecture. I stumbled across this solution:

sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries

May not solve anything for the original asker, but this may help someone.

Side Note: nokogiri has been my highest barrier to using ruby applications. Every time someone depends on a different version I have to figure out how to build it. And my problem is different every time.

蓦然回首 2024-11-05 20:57:31

gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2

这对我有用在 Macos 上。
它也适用于版本 1.6.6.4

gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2

this worked for me on macos.
It works also with version 1.6.6.4

紫竹語嫣☆ 2024-11-05 20:57:31

我正在使用..
操作系统 X 10.9.4
Homebrew 0.9.4

这是我从这个线程成功安装 nokogiri 并修复丢失的 libiconv 的总结。

安装 Homebrew http://brew.sh/
或者使用下面的命令更新到最新版本

brew update

安装 libxml2 libxslt

brew install libxml2 libxslt

链接两个 libxml2 libxslt

brew link libxml2 libxslt

如果您收到使用 --force 的警告,只需使用下面的命令

brew link --force libxml2 libxslt

安装 xCode 命令工具即可安装 libiconv

xcode-select --install

安装 libiconv

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

最后一步,安装 nokogiri!

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

I'm using..
OS X 10.9.4
Homebrew 0.9.4

Here is my summery from this thread to successfully install nokogiri, fixing missing libiconv.

Install Homebrew http://brew.sh/
Or update to latest using command below

brew update

Install libxml2 libxslt

brew install libxml2 libxslt

Link both libxml2 libxslt

brew link libxml2 libxslt

If you get warning to use --force, just use command below

brew link --force libxml2 libxslt

Install xCode command tools to enable you to install libiconv

xcode-select --install

Install libiconv

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

Final step, install nokogiri!

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文