如何在Windows上的“ gem install ovirt-engine-sdk”上解决“ libxml2缺少软件包”错误?

时间:2019-01-18 17:10:08

标签: ruby rubygems libxml2 libxml-ruby ovirt

我正在尝试在Windows 10计算机上运行gem install ovirt-engine-sdk,并且遇到以下问题:

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

我尝试过:

  • 在Windows上安装libxml2
  • 尝试使用所有--without-libxml2-config--without-libxml2-config,...参数
  • 卸载并重新安装Ruby,以便尝试使用其他Ruby版本(我当前的ruby版本为ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]
  • 或多或少尝试我可以找到的有关Stack Overflow相关问题的所有不同答案

我的想法不多了,因此,如果有人可以帮助我摆脱困境,那将不胜感激!

非常感谢您!

1 个答案:

答案 0 :(得分:2)

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

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.