xml4r / libxml-ruby

Libxml bindings for Ruby.
https://xml4r.github.io/libxml-ruby
MIT License
129 stars 71 forks source link

Cannot compile gem on Ruby 2.5 #190

Closed coding-bunny closed 1 year ago

coding-bunny commented 2 years ago

Hello,

I'm running into something weird with this gem on Ruby 2.5 specifically. Here at work we build gems against multiple versions of Ruby to handle legacy requirements, and it seems that the gem has issues finding its dependencies on Ruby 2.5 specifically.

We build against the following versions:

And on all versions, the gem is being build correctly using Appraisal except 2.5:

#!/bin/bash -eo pipefail
bundle config --local path "vendor/bundle"
bundle install --jobs 4 --retry 3
bundle exec appraisal install

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching git@github.com:customink/client_client
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Fetching rake 13.0.6
Installing rake 13.0.6
Fetching zeitwerk 2.6.0
Fetching public_suffix 4.0.7
Fetching minitest 5.4.3
Fetching concurrent-ruby 1.1.10
Installing zeitwerk 2.6.0
Installing minitest 5.4.3
Installing public_suffix 4.0.7
Using bundler 2.3.17
Fetching thor 1.2.1
Installing concurrent-ruby 1.1.10
Installing thor 1.2.1
Fetching awesome_print 1.9.2
Installing awesome_print 1.9.2
Fetching builder 3.2.4
Fetching libxml-ruby 3.2.3
Installing builder 3.2.4
Fetching multipart-post 2.1.1
Installing libxml-ruby 3.2.3 with native extensions
Installing multipart-post 2.1.1
Fetching hashie 5.0.0
Fetching retryable 3.0.5
Installing retryable 3.0.5
Fetching coderay 1.1.3
Installing hashie 5.0.0
Fetching rexml 3.2.5
Installing coderay 1.1.3
Installing rexml 3.2.5
Fetching docile 1.4.0
Installing docile 1.4.0
Fetching dotenv 2.7.6
Fetching method_source 1.0.0
Fetching mocha 1.14.0
Installing dotenv 2.7.6
Installing method_source 1.0.0
Installing mocha 1.14.0
Fetching simplecov-html 0.12.3
Fetching simplecov_json_formatter 0.1.4
Installing simplecov_json_formatter 0.1.4
Fetching vcr 2.9.3
Installing simplecov-html 0.12.3
Installing vcr 2.9.3
Fetching minitest-ci 3.4.0
Installing minitest-ci 3.4.0
Fetching addressable 2.8.0
Fetching appraisal 2.4.1
Installing addressable 2.8.0
Installing appraisal 2.4.1
Fetching faraday 0.17.5
Installing faraday 0.17.5
Fetching i18n 1.11.0
Installing i18n 1.11.0
Fetching tzinfo 2.0.4
Installing tzinfo 2.0.4
Fetching crack 0.4.5
Fetching pry 0.14.1
Installing crack 0.4.5
Fetching simplecov 0.21.2
Installing pry 0.14.1
Installing simplecov 0.21.2
Fetching faraday_middleware 0.14.0
Installing faraday_middleware 0.14.0
Fetching webmock 1.19.0
Fetching activesupport 6.1.6
Installing webmock 1.19.0
Installing activesupport 6.1.6
Using client_client 0.3.0 from git@github.com:customink/client_client (at master@e3ab785)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/root/project/vendor/bundle/ruby/2.5.0/gems/libxml-ruby-3.2.3/ext/libxml
/usr/local/bin/ruby -I /usr/local/lib/ruby/site_ruby/2.5.0 extconf.rb
/usr/local/bin/ruby: warning: shebang line ending with \r may cause problems
checking for libxml/xmlversion.h in
/opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2,/usr/local/include...
no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
*** 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/local/bin/$(RUBY_BASE_NAME)
    --with-xml2-config
    --without-xml2-config
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xml2lib
    --without-xml2lib
    --with-libxml2lib
    --without-libxml2lib
 extconf failure: Cannot find libxml2.

Install the library or try one of the following options to extconf.rb:

  --with-xml2-config=/path/to/xml2-config
  --with-xml2-dir=/path/to/libxml2
  --with-xml2-lib=/path/to/libxml2/lib
  --with-xml2-include=/path/to/libxml2/include

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

/root/project/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/libxml-ruby-3.2.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/root/project/vendor/bundle/ruby/2.5.0/gems/libxml-ruby-3.2.3 for inspection.
Results logged to
/root/project/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/libxml-ruby-3.2.3/gem_make.out

  /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/ext/builder.rb:102:in `run'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/ext/ext_conf_builder.rb:28:in
`build'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/ext/builder.rb:171:in
`build_extension'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/ext/builder.rb:205:in `block in
build_extensions'
  /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/ext/builder.rb:202:in `each'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/ext/builder.rb:202:in
`build_extensions'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/installer.rb:851:in
`build_extensions'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/source/rubygems.rb:209:in
`install'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/installer/gem_installer.rb:54:in
`install'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/installer/parallel_installer.rb:186:in
`do_install'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/worker.rb:62:in
`apply_func'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/worker.rb:57:in
`block in process_queue'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/worker.rb:54:in
`loop'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/worker.rb:54:in
`process_queue'
/usr/local/lib/ruby/gems/2.5.0/gems/bundler-2.3.17/lib/bundler/worker.rb:91:in
`block (2 levels) in create_threads'

An error occurred while installing libxml-ruby (3.2.3), and Bundler
cannot continue.

In Gemfile:
  payment_client was resolved to 1.10.0, which depends on
    braintree was resolved to 3.4.0, which depends on
      libxml-ruby

Exited with code exit status 5

CircleCI received exit code 5

When looking at the other Ruby versions, they all install without problem. All the containers are identical when it comes to installed packages, the only difference is the installed Ruby version.

cfis commented 1 year ago

The error message says:

/opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2,/usr/local/include...
no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no

So the libxml libraries are not being found. Perhaps the way Ruby 2.5 was compiled changes its default search path for headers? Try manually specifying the '--with-xml2-include' option.