Jrinard
Jrinard

Reputation: 155

How do I fix bundle install error regarding nokogiri?

I'm getting this error when I'm trying to bundle install an older project. I'm stuck and not sure how to fix this. I'm getting error on multiple projects. Is there a way to maintenance it? I've tried bundle update. Does anyone have any ideas? I upgraded to macOS Mojave 10.14.6. Thank you

    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

Upvotes: 0

Views: 2986

Answers (1)

RomanOks
RomanOks

Reputation: 712

Run these commands:

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

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

sometimes mac updates can break xcode CLI so reinstalling can fix the issue: https://github.com/sparklemotion/nokogiri/issues/1445

*

https://stackoverflow.com/a/37757604/11544569

*

Upvotes: 3

Related Questions