首页 > 解决方案 > Mojave 10.14 上的 Nokogumbo 安装无法正常工作

问题描述

我在更新RailsRuby的最新安全更新后尝试运行 bundle install ,但无法安装 Nokogumbo gem。我收到以下错误消息:

An error occurred while installing nokogumbo (1.5.0), and Bundler cannot continue.
Make sure that `gem install nokogumbo -v '1.5.0' --source 'https://rubygems.org/'` succeeds before bundling.

我尝试运行gem install nokogumbo -v '1.5.0' --source 'https://rubygems.org/'并得到了这个:

Building native extensions. This could take a while...
ERROR:  Error installing nokogumbo:
    ERROR: Failed to build gem native extension.

    current directory: /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogumbo-1.5.0/ext/nokogumboc
/Users/<username>/.rbenv/versions/2.6.2/bin/ruby -I /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/2.6.0 -r ./siteconf20190314-8398-fmosg1.rb extconf.rb
checking for xmlNewDoc() in -lxml2... yes
checking for nokogiri.h in /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri... no
checking if the C compiler accepts  -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.9
with the following patches applied:
    - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

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

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Activating libxml2 2.9.9 (from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ports/x86_64-apple-darwin18.2.0/libxml2/2.9.9)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.33.

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
*** 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/<username>/.rbenv/versions/2.6.2/bin/$(RUBY_BASE_NAME)
    --with-xml2lib
    --without-xml2lib
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-pkg-config
    --without-pkg-config
    --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/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:293:in `verify_file': Downloaded file '/Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ports/archives/libxslt-1.1.33.tar.gz' has wrong hash: expected: 8e36605144409df979cab43d835002f63988f3dc94d5d3537c12796db90e38c8 is: d020ac32fcb0778e2f636fc31ac205f3f00aceec08c61a090fefa30110daaddc (RuntimeError)
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:61:in `block in extract'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:60:in `each'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:60:in `extract'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:151:in `cook'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:365:in `block (2 levels) in process_recipe'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:257:in `block in chdir_for_build'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:256:in `chdir'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:256:in `chdir_for_build'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:364:in `block in process_recipe'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:262:in `tap'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:262:in `process_recipe'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:574:in `<top (required)>'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from extconf.rb:17:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogumbo-1.5.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogumbo-1.5.0 for inspection.
Results logged to /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogumbo-1.5.0/gem_make.out

我也尝试运行该错误消息中建议的所有命令。使用该bundle config命令,我收到一条消息,说“您正在替换 build.nokogiri 的当前全局值,当前为“--use-system-libraries=true”等。

我还尝试手动安装 nokogumbo 1.4.7,以查看安装可以升级的旧版本 gem 是否有帮助。没运气。这是没有意义的,因为在他们的机器上与我具有相同设置的人能够很好地安装所有东西。

任何人都知道我可以做些什么不同的事情吗?谢谢!

更新 - 已解决

修复(针对 Mojave 10.14)是:gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 --use-system-libraries

信用在这里

标签: ruby-on-railsrubynokogirinokogumbo

解决方案


尝试在 rails 中运行 bundler 时遇到了同样的问题。对我有用的是运行

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

--use-system-libraries为 nokogumbo设置标志就可以了。


推荐阅读