Search code examples
rubyrubygemslibxml2libxml-rubyovirt

How to solve "libxml2 missing package" error on "gem install ovirt-engine-sdk" on Windows?


I am trying to run gem install ovirt-engine-sdk on a Windows 10 machine and I am facing the following issue:

extconf.rb:29:in `<main>': The "libxml2" package isn't available. (RuntimeError)

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

C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/ovirt-engine-sdk-4.2.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/ovirt-engine-sdk-4.2.5 for inspection.
Results logged to
C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/ovirt-engine-sdk-4.2.5/gem_make.out

An error occurred while installing ovirt-engine-sdk (4.2.5), and Bundler cannot
continue.
Make sure that `gem install ovirt-engine-sdk -v '4.2.5'` succeeds before
bundling.

In Gemfile:
  fog was resolved to 2.1.0, which depends on
    fog-ovirt was resolved to 1.1.2, which depends on
      ovirt-engine-sdk

I have tried to :

  • install libxml2 on Windows
  • try with all the --without-libxml2-config, --without-libxml2-config, ... parameters
  • uninstall and re-install Ruby, in order to try with other Ruby versions (my current ruby version is ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]
  • try more or less all the different answers I could find about related issues on Stack Overflow

I am running out of ideas so if someone could have any clue to get me out of this, that would be much appreciated!

Thank you so much!


Solution

  • I'm unfamiliar with ovirt-engine-sdk, and can't find any information on their github to imply they support windows (it's not guaranteed, especially for gems with native extensions). But we can definitely work around this particular error. To help show you how to deal with similar problems in the future, here's my process to troubleshoot this.

    $ gem fetch ovirt-engine-sdk
    $ gem unpack ovirt-engine-sdk-4.3.0.gem
    $ cat ovirt-engine-sdk-4.3.0/ext/ovirtsdk4c/extconf.rb
    

    The relevant portion is here (found by searching for the error message):

    xml2_config = find_executable('xml2-config')
    if xml2_config
      # other stuff
    elsif !pkg_config('libxml2')
      raise 'The "libxml2" package isn\'t available.'
    end
    

    We can see it's checking for an executable named xml2-config. According to the documentation for find_executable, it checks your path for that.

    So, this means we need two things to fix this error:

    1. The xml2-config executable
    2. We need to add that to our path. It sounds like this is the step you're missing.

    You can download from here - Then add the entire bin folder to your path.