rubys / nokogumbo

A Nokogiri interface to the Gumbo HTML5 parser.
Apache License 2.0
186 stars 114 forks source link

An error occurred while installing nokogumbo (2.0.4), and Bundler #173

Closed pavlenex closed 3 years ago

pavlenex commented 3 years ago

Hello, I'm trying to build this project https://github.com/BitcoinDesign/Guide on a freshly installed mAC m1, and I'm getting the following errors. I've done a fresh clean re-install of my OS just because of this error, and unfortunately, it didn't resolve it.

Any ideas what might be wrong here?

Enviroment

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/private/var/folders/y3/md4h281x1s54bf0qvn95fk4m0000gn/T/bundler20210318-4674-y5zbnpnokogumbo-2.0.4/gems/nokogumbo-2.0.4/ext/nokogumbo
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210318-4674-1qd50j6.rb extconf.rb
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`require': cannot load such file -- nokogiri/nokogiri (LoadError)
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`rescue in require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in
`require'
from
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri.rb:32:in
`rescue in <top (required)>'
from
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri.rb:11:in
`<top (required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`rescue in require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in
`require'
    from extconf.rb:4:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require': cannot load such file -- nokogiri/nokogiri (LoadError)
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
from
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri.rb:32:in
`rescue in <top (required)>'
from
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri.rb:11:in
`<top (required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`rescue in require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in
`require'
    from extconf.rb:4:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require':
dlopen(/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri/2.6/nokogiri.bundle,
0x0009): could not use
'/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri/2.6/nokogiri.bundle'
because it is not a compatible arch -
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri/2.6/nokogiri.bundle
(LoadError)
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
from
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri.rb:13:in
`<top (required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in
`rescue in require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in
`require'
    from extconf.rb:4:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require': cannot load such file -- nokogiri (LoadError)
from
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
    from extconf.rb:4:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in
/var/folders/y3/md4h281x1s54bf0qvn95fk4m0000gn/T/bundler20210318-4674-y5zbnpnokogumbo-2.0.4/gems/nokogumbo-2.0.4
for inspection.
Results logged to
/var/folders/y3/md4h281x1s54bf0qvn95fk4m0000gn/T/bundler20210318-4674-y5zbnpnokogumbo-2.0.4/extensions/universal-darwin-20/2.6.0/nokogumbo-2.0.4/gem_make.out

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

In Gemfile:
  html-proofer was resolved to 3.18.0, which depends on
    nokogumbo
pavlenex commented 3 years ago

Okay so the problem was indeed the M1 chip incompatibility.

1. Go to your applications > utilities folder.
2. Right click and click "Get Info" on your terminal app
3. Check "Open Using Rosetta" option
4. Start your terminal app
5. bundle install 

This was helpful https://github.com/CocoaPods/CocoaPods/issues/10220#issuecomment-736118564

flavorjones commented 3 years ago

@pavlenex Based on the log including this file path:

/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.0-x86_64-darwin/lib/nokogiri.rb

it looks like you've installed the x86_64-darwin native platform gem, and not the arm64-darwin native platform gem. This shouldn't happen on an M1, and indicates that something deeper is wrong. Would you mind opening an issue with the Nokogiri project at https://github.com/sparklemotion/nokogiri/issues/new/choose ?

flavorjones commented 3 years ago

Is it possible that you're using the Mac system ruby? There are known issues between bundler and that version of ruby (which Apple patches), see https://github.com/rubygems/rubygems/issues/4234 for details.

Someone else has written an essay about other issues with the Mac system ruby at https://mac.install.guide/faq/do-not-use-mac-system-ruby/index.html

pavlenex commented 3 years ago

Hey @flavorjones indeed it's Mac's default (system) Ruby. Thanks I'll have a look as I'm still facing some issues, could be that - thanks!

kirykr commented 2 years ago

Thank to @flavorjones. I fixed the issue. In my machine, there are two nokogiri gems installed. Select gem to uninstall:

  1. nokogiri-1.10.10
  2. nokogiri-1.13.8-x86_64-linux

    So I uninstalled the second one and ran bundle install again and it worked fine.