如何解决 Windows 上 "gem install ovirt-engine-sdk" 上的 "libxml2 missing package" 错误?

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

我正在尝试 运行 gem install ovirt-engine-sdk 在 Windows 10 机器上,我面临以下问题:

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

我试过:

我 运行 没有想法,所以如果有人能提供任何线索让我摆脱困境,那将不胜感激!

非常感谢!

我不熟悉 ovirt-engine-sdk,并且在他们的 github 上找不到任何信息来暗示他们支持 windows(不能保证,特别是对于带有原生扩展的 gem ).但我们绝对可以解决这个特定错误。为了帮助您了解以后如何处理类似问题,以下是我解决此问题的过程。

$ 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

相关部分在这里(通过搜索错误信息找到):

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

我们可以看到它正在检查名为 xml2-config 的可执行文件。根据 documentation for find_executable,它会为此检查您的路径。

所以,这意味着我们需要两件事来修复这个错误:

  1. xml2-config 可执行文件
  2. 我们需要将其添加到我们的路径中。听起来这是你缺少的步骤。

您可以从 here 下载 - 然后将整个 bin 文件夹添加到您的路径中。