'Ruby gem install fails: failed to build gem native extension

I'm using win10. I've tried updating ruby, installing ruby with development kit, running ridk install, none worked. Here is the error message I'm getting:

Please help...

Temporarily enhancing PATH for MSYS/MINGW... Building native extensions. This could take a while... ERROR: Error installing mspire: ERROR: Failed to build gem native extension.

current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/nokogiri-1.6.8.1/ext/nokogiri

C:/Ruby30-x64/bin/ruby.exe -I C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0 -r ./siteconf20220329-1208-397ap8.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.1.0


IMPORTANT NOTICE:

Building Nokogiri with a packaged version of zlib-1.2.8.

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

404 Not Found *** 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=C:/Ruby30-x64/bin/$(RUBY_BASE_NAME) --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 C:/Ruby30-x64/lib/ruby/3.0.0/digest.rb:50:in initialize': No such file or directory @ rb_sysopen - C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/nokogiri-1.6.8.1/ports/archives/zlib-1.2.8.tar.gz (Errno::ENOENT) from C:/Ruby30-x64/lib/ruby/3.0.0/digest.rb:50:in open' from C:/Ruby30-x64/lib/ruby/3.0.0/digest.rb:50:in file' from C:/Ruby30-x64/lib/ruby/3.0.0/digest.rb:35:in file' from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:257:in verify_file' from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:51:in block in download' from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:49:in each' from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:49:in download' from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:14 from extconf.rb:365:in block (2 levels) in process_recipe' from extconf.rb:257:in chdir' from extconf.rb:257:in chdir_for_build' from extconf.rb:364:in block in process_recipe' from <internal:kernel>:90:in tap' from extconf.rb:263:in process_recipe' from extconf.rb:483:in `<main>'

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

C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/nokogiri-1.6.8.1/mkmf.log

extconf failed, exit code 1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source