rails 无法安装 nokogiri w Mavericks & rbenv



运行OSX 10.9.4和XCode 5.1.1,我最近从rvm切换到Rbenv,所以我需要重新安装一些宝石,不是什么大问题,但是…

我在安装Nokogiri gem时卡住了,即使在下载并安装了XCode命令行工具的十月版本并运行:

sudo xcode-select -s /Library/Developer/CommandLineTools/

我还安装了libxml2 libxslt w brew

我仍然得到一个错误,有什么办法解决这个问题吗?

    yves$ gem install nokogiri
    Building native extensions.  This could take a while...
    Building nokogiri using packaged libraries.
    ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.
        /Users/yves/.rbenv/versions/2.1.2/bin/ruby extconf.rb
    Building nokogiri using packaged libraries.
    checking for iconv.h... *** 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=/Users/yves/.rbenv/versions/2.1.2/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
    /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
    You have to install development tools first.
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
        from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1066:in `have_header'
        from extconf.rb:103:in `have_iconv?'
        from extconf.rb:148:in `block (2 levels) in iconv_prefix'
        from extconf.rb:90:in `preserving_globals'
        from extconf.rb:143:in `block in iconv_prefix'
        from extconf.rb:120:in `each_iconv_idir'
        from extconf.rb:137:in `iconv_prefix'
        from extconf.rb:427:in `block in <main>'
        from extconf.rb:161:in `block in process_recipe'
        from extconf.rb:154:in `tap'
        from extconf.rb:154:in `process_recipe'
        from extconf.rb:422:in `<main>'
    extconf failed, exit code 1
    Gem files will remain installed in /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3 for inspection.
    Results logged to /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3/gem_make.out

当安装libxml2 libxslt时,我收到一个警告,它可能会干扰nokogiri的安装?

             yves$ brew install libxml2 libxslt
        ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libxml2-2.9
        ######################################################################## 100.0%
        ==> Pouring libxml2-2.9.1.mavericks.bottle.1.tar.gz
        ==> Caveats
        This formula is keg-only, so it was not symlinked into /usr/local.
        Mac OS X already provides this software and installing another version in
        parallel can cause all kinds of trouble.
        Generally there are no consequences of this for you. If you build your
        own software and it requires this formula, you'll need to add to your
        build variables:
            LDFLAGS:  -L/usr/local/opt/libxml2/lib
            CPPFLAGS: -I/usr/local/opt/libxml2/include

接下来我该怎么做?谢谢你的建议

几个星期前我得到了同样的错误。我是这样解决的:

您必须手动安装损坏的库。使用Homebrew,这是OS x的软件包管理器。确保先更新brew update,然后安装库:

brew install libxml2 libxslt
brew link libxml2 libxslt

您可能必须从源代码安装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

然后你就可以安装gem了。

引用自文档:http://nokogiri.org/tutorials/installing_nokogiri.html homebrew_09

您可能还需要在安装库后运行rbenv rehash

我在一个论坛上找到了解决方案:

https://github.com/sparklemotion/nokogiri/issues/1111

经过近一周的搜索,终于找到了:

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri -- --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

GL

几天前我遇到了同样的问题,这个帖子帮助了我

https://github.com/sparklemotion/nokogiri/issues/1111

最后为我工作的命令

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

相关内容

  • 没有找到相关文章

最新更新