rubys / nokogumbo

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

html-proofer depends on nokogumbo #181

Closed am-root closed 2 years ago

am-root commented 2 years ago

Hello, I am installing the dependencies from this repo. Generated and cloned the repo, ran bundle when I encountered this issue. I tried to install nokogumbo using gem install nokogumbo

ruby version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]

nokogiri version: nokogiri: version: 1.12.5

OS version: Linux parrot 5.14.0-2parrot1-amd64 #1 SMP Debian 5.14.6-2parrot1 (2021-09-25) x86_64 GNU/Linux

-----Error starts------

Fetching nokogumbo 2.0.5 Installing nokogumbo 2.0.5 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /tmp/bundler20211031-7207-3pl4hpnokogumbo-2.0.5/gems/nokogumbo-2.0.5/ext/nokogumbo /usr/bin/ruby2.7 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20211031-7207-1vgand7.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=/usr/bin/$(RUBY_BASE_NAME)2.7 /usr/lib/ruby/vendor_ruby/nokogiri/xml/xpath/syntax_error.rb:4:in module:XML': XPath is not a class (TypeError) /var/lib/gems/2.7.0/gems/nokogiri-1.12.5-x86_64-linux/lib/nokogiri/2.7/nokogiri.so:0: previous definition of XPath was here from /usr/lib/ruby/vendor_ruby/nokogiri/xml/xpath/syntax_error.rb:3:in module:Nokogiri' from /usr/lib/ruby/vendor_ruby/nokogiri/xml/xpath/syntax_error.rb:2:in <top (required)>' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:96:in require' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:96:in require' from /usr/lib/ruby/vendor_ruby/nokogiri/xml/xpath.rb:2:in <top (required)>' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:96:in require' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:96:in require' from /usr/lib/ruby/vendor_ruby/nokogiri/xml.rb:21:in <top (required)>' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:96:in require' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:96:in require' from /usr/lib/ruby/vendor_ruby/nokogiri.rb:36:in <top (required)>' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in require' from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in require' from extconf.rb:4:in

' extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20211031-7207-3pl4hpnokogumbo-2.0.5/gems/nokogumbo-2.0.5 for inspection. Results logged to /tmp/bundler20211031-7207-3pl4hpnokogumbo-2.0.5/extensions/x86_64-linux/2.7.0/nokogumbo-2.0.5/gem_make.out

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

In Gemfile: html-proofer was resolved to 3.19.2, which depends on nokogumbo

-----Error ends------

Can you please help me resolve this? I am inexperienced and could not find any blog related to this.

flavorjones commented 2 years ago

Hi @am-root, sorry you're having problems. I'll try to help!

Summary: Please try apt remove ruby-nokogiri followed by apt autoremove to get rid of the Nokogiri debian package. After that it should work fine.

Explanation

This is the key error from the output you shared:

/usr/lib/ruby/vendor_ruby/nokogiri/xml/xpath/syntax_error.rb:4:in module:XML': XPath is not a class (TypeError)
/var/lib/gems/2.7.0/gems/nokogiri-1.12.5-x86_64-linux/lib/nokogiri/2.7/nokogiri.so:0: previous definition of XPath was here

I see that you have two different installations of Nokogiri:

I'm guessing the /usr/lib version is a debian package based on v1.11.1 or earlier -- which is beforeXPath was changed from a class to a module -- and the other version is something a different package manager has installed.

I don't recommend using debian packages for Ruby gems -- especially if you're using bundler or gem install for other gems -- because they tend to collilde in unpleasant ways like this.

am-root commented 2 years ago

@flavorjones Thank you, sir! I understood the error and solved it with your great help <3

flavorjones commented 2 years ago

Great! Thanks for closing the loop.