【问题标题】:Failure to install nokogiri libiconv is missing on Yosemite Mac OS X 10.10Yosemite Mac OS X 10.10 上缺少安装 nokogiri libiconv 失败
【发布时间】:2014-09-02 21:24:59
【问题描述】:

尝试安装 Nokogiri 我收到以下错误

Maxims-MacBook-Air:ScrapingTheApple maximveksler$ gem install nokogiri
Fetching: nokogiri-1.6.2.1.gem (100%)
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/maximveksler/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
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=/Users/maximveksler/.rvm/rubies/ruby-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

extconf failed, exit code 1

Gem files will remain installed in /Users/maximveksler/.rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/maximveksler/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.2.1/gem_make.out

【问题讨论】:

    标签: gem nokogiri osx-yosemite


    【解决方案1】:

    我建议更新 Oskar 的答案,将 MacOSX10.9.sdk 替换为 MacOSX10.10.sdk,在 OS X 10.10 上测试

    gem install nokogiri -- \
    --with-iconv-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib \
    --with-iconv-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
    

    【讨论】:

    【解决方案2】:

    没有 brew 和其他东西:

    xcode-select --install 
    gem install nokogiri -- --use-system-libraries
    

    【讨论】:

      【解决方案3】:

      我也遇到了这个问题,对我来说这是因为在 Mavericks 下安装了 macports,并且没有将设置迁移到 Yosemite。

      按照此处的说明进行操作:

      http://trac.macports.org/wiki/Migration

      允许我安装旧版本的 Nokogiri (1.5.x),它是 rspec-puppet 的依赖项

      【讨论】:

        【解决方案4】:

        以防万一有人仍然无法像我使用上述解决方案那样解决它,那么这是替代方法

        gem install nokogiri -- --user-system-libraries

        或使用捆绑包

        捆绑配置 build.nokogiri --use-system-libraries

        捆绑安装

        感谢http://www.nokogiri.org/tutorials/installing_nokogiri.html

        【讨论】:

          【解决方案5】:

          我也遇到了同样的问题,安装命令行工具后,

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

          不一定有效,因为它一直说检查软件更新(它已经是最新版本)。相反,我使用了sudo gem install nokogiri --pre,它最终起作用了

          【讨论】:

            【解决方案6】:

            在带有 XCode 6.1 的 10.9 上,我不得不输入 --use-system-libraries,因为自定义的 libxslt 快要死了。

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

            【讨论】:

              【解决方案7】:

              在我的情况下,我升级了 Xcode,忘记安装命令行工具,所以 install 无法运行编译器。

              以下安装命令行工具:

              xcode-select --install

              【讨论】:

                【解决方案8】:

                nokogiri install tutorial 提供解决方案:

                # bash
                brew unlink gcc
                gem uninstall nokogiri
                xcode-select --install
                gem install nokogiri
                

                如果您还没有 Xcode 6.1,您可以从 apple developer download site其他工具部分)安装它,如 this blog post 中所述。

                【讨论】:

                • 我已经这样做了好几次了,每次都忘记这是最简单快捷的解决方案。即使您安装了 Xcode 并且一直在使用它,仍然需要运行 Xcode-select --install
                • 也适用于 macOS Sierra。
                【解决方案9】:

                我成功了:

                gem install nokogiri -- \
                --with-iconv-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib \
                --with-iconv-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
                

                【讨论】:

                  【解决方案10】:

                  这似乎是让 nokogiri 安装,还不确定运行状态。

                  brew install libiconv
                  gem install nokogiri -- --with-iconv-include=/usr/local/opt/libiconv/include/ --with-iconv-lib=/usr/local/opt/libiconv/lib/
                  

                  安装日志:

                  Maxims-MacBook-Air:ScrapingTheApple maximveksler$ gem install nokogiri -- --with-iconv-include=/usr/local/opt/libiconv/include/ --with-iconv-lib=/usr/local/opt/libiconv/lib/
                  Building native extensions with: '--with-iconv-include=/usr/local/opt/libiconv/include/ --with-iconv-lib=/usr/local/opt/libiconv/lib/'
                  This could take a while...
                  Building nokogiri using packaged libraries.
                  Building libxml2-2.8.0 for nokogiri with the following patches applied:
                      - 0001-Fix-parser-local-buffers-size-problems.patch
                      - 0002-Fix-entities-local-buffers-size-problems.patch
                      - 0003-Fix-an-error-in-previous-commit.patch
                      - 0004-Fix-potential-out-of-bound-access.patch
                      - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
                      - 0006-Do-not-fetch-external-parsed-entities.patch
                      - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
                      - 0008-Improve-handling-of-xmlStopParser.patch
                      - 0009-Fix-a-couple-of-return-without-value.patch
                      - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
                      - 0011-Do-not-fetch-external-parameter-entities.patch
                  ************************************************************************
                  IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.
                  
                  If this is a concern for you and you want to use the system library
                  instead, abort this installation process and reinstall nokogiri as
                  follows:
                  
                      gem install nokogiri -- --use-system-libraries
                  
                  If you are using Bundler, tell it to use the option:
                  
                      bundle config build.nokogiri --use-system-libraries
                      bundle install
                  
                  However, note that nokogiri does not necessarily support all versions
                  of libxml2.
                  
                  For example, libxml2-2.9.0 and higher are currently known to be broken
                  and thus unsupported by nokogiri, due to compatibility problems and
                  XPath optimization bugs.
                  ************************************************************************
                  Building libxslt-1.1.28 for nokogiri with the following patches applied:
                      - 0001-Adding-doc-update-related-to-1.1.28.patch
                      - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
                      - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
                      - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
                      - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
                      - 0007-Separate-function-for-predicate-matching-in-patterns.patch
                      - 0008-Fix-direct-pattern-matching.patch
                      - 0009-Fix-certain-patterns-with-predicates.patch
                      - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
                      - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
                      - 0014-Fix-for-bug-436589.patch
                      - 0015-Fix-mkdir-for-mingw.patch
                  ************************************************************************
                  IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.
                  
                  If this is a concern for you and you want to use the system library
                  instead, abort this installation process and reinstall nokogiri as
                  follows:
                  
                      gem install nokogiri -- --use-system-libraries
                  
                  If you are using Bundler, tell it to use the option:
                  
                      bundle config build.nokogiri --use-system-libraries
                      bundle install
                  ************************************************************************
                  Successfully installed nokogiri-1.6.2.1
                  Parsing documentation for nokogiri-1.6.2.1
                  Installing ri documentation for nokogiri-1.6.2.1
                  Done installing documentation for nokogiri after 4 seconds
                  1 gem installed
                  

                  【讨论】:

                  • nokogiri 之后的命令中的连字符错误。这对我有用gem install nokogiri -- --with-iconv-include=/usr/local/opt/libiconv/include/ --with-iconv-lib=/usr/local/opt/libiconv/lib/
                  • @crcastle 已修复。由 Mac 自动替换文本引起。
                  猜你喜欢
                  • 2011-07-28
                  • 1970-01-01
                  • 1970-01-01
                  • 2014-12-25
                  • 2016-05-16
                  • 1970-01-01
                  • 2014-07-24
                  • 2015-10-24
                  • 1970-01-01
                  相关资源
                  最近更新 更多