如何修复有关 nokogiri 的捆绑包安装错误?

How do I fix bundle install error regarding nokogiri?

我在尝试捆绑安装旧项目时遇到此错误。我被卡住了,不知道如何解决这个问题。我在多个项目上遇到错误。有办法保养吗?我试过捆绑更新。有人有什么想法吗?我升级到 macOS Mojave 10.14.6。谢谢

    Fetching nokogiri 1.10.4
Installing nokogiri 1.10.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/myname/.gem/ruby/2.5.1/gems/nokogiri-1.10.4/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20190822-3395-a2lga2.rb extconf.rb
checking if the C compiler accepts  -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... *** 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
    --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=/usr/local/Cellar/ruby/2.5.1/bin/$(RUBY_BASE_NAME)
    --help
    --clean
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
    from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
    from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:416:in `<main>'

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

  /Users/myname/.gem/ruby/2.5.1/extensions/x86_64-darwin-17/2.5.0/nokogiri-1.10.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/myname/.gem/ruby/2.5.1/gems/nokogiri-1.10.4 for inspection.
Results logged to /Users/myname/.gem/ruby/2.5.1/extensions/x86_64-darwin-17/2.5.0/nokogiri-1.10.4/gem_make.out

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

In Gemfile:
  recurring_select was resolved to 2.0.0, which depends on
    rails was resolved to 5.0.7.2, which depends on
      actioncable was resolved to 5.0.7.2, which depends on
        actionpack was resolved to 5.0.7.2, which depends on
          actionview was resolved to 5.0.7.2, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri
Joshuas-iMac:momentum-master myname$ 

```git

运行 这些命令:

gem uninstall nokogiri
xcode-select --install
gem install nokogiri

来源:http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x

有时 mac 更新会破坏 xcode CLI,因此重新安装可以解决问题:https://github.com/sparklemotion/nokogiri/issues/1445

*

*