Search code examples
ruby-on-railsrubyrubygemsnokogiriruby-on-rails-6

nokogiri installation error on MacOS Catalina while bundle install


I ran into a new nokogiri problem and I tried every possible solution I could find online on Stack Overflow. My ruby version is 3.0.1, rbenv is 1.1.2 and rails is 6.4.1. When I run "bundle install" I get the following error and I have no clue how to fix it. The error in itself is very long so I posting the entire thing! Any help would be appreciated! Thanks!!

Fetching gem metadata from https://rubygems.org/............
Resolving dependencies....
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using minitest 5.14.4
.
.
.
Fetching nokogiri 1.12.3
Using activerecord 6.1.4.1
Using activejob 6.1.4.1
Using jbuilder 2.11.2
Using spring 2.1.1
Installing nokogiri 1.12.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/zerad/coding
Projects/rubyProjects/environment/testapp/vendor/cache/ruby/3.0.0/gems/nokogiri-1.12.3/ext/nokogiri
/Users/zerad/.rbenv/versions/3.0.1/bin/ruby -I
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0 -r
./siteconf20210827-1071-swdvid.rb extconf.rb --use-system-libraries
--with-xml2-include\=/usr/local/opt/libxml2/include/libxml2
checking for whether -std=c99 is accepted as CFLAGS... yes
checking for whether -Wno-declaration-after-statement is accepted as CFLAGS...
yes
checking for whether -g is accepted as CFLAGS... yes
checking for whether -Winline is accepted as CFLAGS... yes
checking for whether -Wmissing-noreturn is accepted as CFLAGS... yes
checking for whether
-Wno-error=unused-command-line-argument-hard-error-in-future is accepted as
CFLAGS... no
checking for whether
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 is
accepted as CPPFLAGS... yes
Building nokogiri using system libraries.
checking for gzdopen() in -lz... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
Using mini_portile version 2.6.1
---------- IMPORTANT NOTICE ----------
Building Nokogiri with a packaged version of libgumbo-1.0.0-nokogiri.
Configuration options: --enable-shared --disable-static
Copying gumbo-parser files into
tmp/x86_64-apple-darwin19/ports/libgumbo/1.0.0-nokogiri/gumbo-parser...
Running 'compile' for libgumbo 1.0.0-nokogiri... OK
Activating libgumbo 1.0.0-nokogiri (from
ports/x86_64-apple-darwin19/libgumbo/1.0.0-nokogiri)...
checking for whether -I/Users/zerad/coding
Projects/rubyProjects/environment/testapp/vendor/cache/ruby/3.0.0/gems/nokogiri-1.12.3/ext/nokogiri/ports/x86_64-apple-darwin19/libgumbo/1.0.0-nokogiri/include
is accepted as CPPFLAGS... no
checking for gumbo_parse_with_options() in gumbo.h... no
-----
extconf.rb:276:in `ensure_func'
gumbo_parse_with_options is missing. Please locate mkmf.log to investigate how
it is failing.
-----
*** 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/zerad/.rbenv/versions/3.0.1/bin/$(RUBY_BASE_NAME)
    --help
    --clean
    --prevent-strip
    --enable-system-libraries
    --disable-system-libraries
    --use-system-libraries
    --enable-system-libraries
    --disable-system-libraries
    --use-system-libraries
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-z-dir
    --without-z-dir
    --with-z-include
    --without-z-include=${z-dir}/include
    --with-z-lib
    --without-z-lib=${z-dir}/lib
    --with-zlib
    --without-zlib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xml2lib
    --without-xml2lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include
    --without-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-xsltlib
    --without-xsltlib
    --with-exslt-dir
    --without-exslt-dir
    --with-exslt-include
    --without-exslt-include=${exslt-dir}/include
    --with-exslt-lib
    --without-exslt-lib=${exslt-dir}/lib
    --with-exsltlib
    --without-exsltlib
    --enable-cross-build
    --disable-cross-build

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

/Users/zerad/coding
Projects/rubyProjects/environment/testapp/vendor/cache/ruby/3.0.0/extensions/x86_64-darwin-19/3.0.0/nokogiri-1.12.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/zerad/coding
Projects/rubyProjects/environment/testapp/vendor/cache/ruby/3.0.0/gems/nokogiri-1.12.3
for inspection.
Results logged to /Users/zerad/coding
Projects/rubyProjects/environment/testapp/vendor/cache/ruby/3.0.0/extensions/x86_64-darwin-19/3.0.0/nokogiri-1.12.3/gem_make.out

/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:92:in
`run'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:47:in
`block in build'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/3.0.0/tempfile.rb:317:in
`open'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:26:in
`build'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:158:in
`build_extension'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:192:in
`block in build_extensions'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:189:in
`each'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:189:in
`build_extensions'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/rubygems/installer.rb:837:in
`build_extensions'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/rubygems_gem_installer.rb:66:in
`build_extensions'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/rubygems_gem_installer.rb:26:in
`install'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/source/rubygems.rb:192:in
`install'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/installer/gem_installer.rb:54:in
`install'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/installer/gem_installer.rb:59:in
`block in install_with_settings'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/rubygems_integration.rb:556:in
`install_with_build_args'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/installer/gem_installer.rb:59:in
`install_with_settings'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/installer/parallel_installer.rb:186:in
`do_install'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/worker.rb:62:in
`apply_func'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/worker.rb:57:in
`block in process_queue'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/worker.rb:54:in
`loop'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/worker.rb:54:in
`process_queue'
/Users/zerad/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/worker.rb:91:in
`block (2 levels) in create_threads'

An error occurred while installing nokogiri (1.12.3), and Bundler
cannot continue.

In Gemfile:
  rails was resolved to 6.1.4.1, which depends on
    actioncable was resolved to 6.1.4.1, which depends on
      actionpack was resolved to 6.1.4.1, which depends on
        actionview was resolved to 6.1.4.1, which depends on
          rails-dom-testing was resolved to 2.0.3, which depends on
            nokogiri

Solution

  • Try reinstalling everything.

    I ended up here after using Ruby on Rails after a few months. Deleted Ruby and cleaned everything up, reinstalled both ruby and rails using rbenv, and updated yarn. Followed the tutorial on goRails and made sure there were no anomalies.

    For example, if you installed ruby 3.0.1 but "ruby -v" gives you 2.7.2, there's a problem. If you installed rails 6.1.3 but it shows 6.1.4, that's another problem.