【问题标题】:Bundler v2.0.2 refuses to install libxml-ruby 3.1.0 on Mac OS CatalinaBundler v2.0.2 拒绝在 Mac OS Catalina 上安装 libxml-ruby 3.1.0
【发布时间】:2019-12-15 22:42:30
【问题描述】:

我找到了如何使用gem install 命令安装libxml-ruby 的所有答案:

gem install libxml-ruby -v '3.1.0' -- --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include

效果很好!但随后立即运行:

bundle install

给出无用的错误:

Fetching libxml-ruby 3.1.0
Installing libxml-ruby 3.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/me/myApp/code/myApp/.gems/ruby/2.6.0/gems/libxml-ruby-3.1.0/ext/libxml
/Users/me/.rbenv/versions/2.6.3/bin/ruby -I /Users/me/.rbenv/versions/2.6.3/lib/ruby/2.6.0 -r ./siteconf20191215-25200-16wtr3.rb extconf.rb --with-xml2-config\=/usr/local/opt/libxml2/bin/xml2-config\
--with-xml2-dir\=/usr/local/opt/libxml2\ --with-xml2-lib\=/usr/local/opt/libxml2/lib\ --with-xml2-include\=/usr/local/opt/libxml2/include
/Users/me/.rbenv/versions/2.6.3/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... *** 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=/Users/me/.rbenv/versions/2.6.3/bin/$(RUBY_BASE_NAME)
    --with-xml2-config

好的,看起来 libxml2 选项未包含在捆绑程序用于安装的调用中。所以让我们这样做:

bundle config build.libxml-ruby --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include

应该可以的,对吧?不,它没有。在我能让 Bundler 做它应该做的事情之前,我已经死在了水里。

对于 Bundler 为何会在此处失败,没有很好的答案。 gem install 行有效。捆绑器失败。

mkmf.log 文件里面是这样的:

find_header: checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... -------------------- no

然后是一些与无法找到该头文件有关的失败。

它正在查看/opt/,而不是/usr/local/opt。如果 Bundler 不遵守捆绑配置命令,我不知道如何让 Bundler 出现在正确的位置。

【问题讨论】:

    标签: ruby rubygems bundler libxml2


    【解决方案1】:

    由于 Bundler 不支持我传入的路径,因此我查看了它正在寻找 xmlversion.h 的路径。

    我进入/usr/local/include。这就是我所有的 Homebrew 链接所在的位置。我创建了一个指向 Mac OS 提供的 libxml 目录的符号链接:

    ln -s /usr/local/opt/libxml2/include/libxml2/libxml libxml
    

    /usr/local/opt 似乎是一个奇怪的系统目录位置,但我已经厌倦了它。

    一旦我这样做了,然后回到我的应用程序目录,bundle install 就起作用了。好吧,我的意思是它又坏了,但这次是在therubyracer。所以它至少跳过了这个障碍。

    【讨论】:

      猜你喜欢
      • 2020-02-28
      • 2021-06-23
      • 1970-01-01
      • 2020-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-14
      • 1970-01-01
      相关资源
      最近更新 更多