Bundler v2.0.2 拒绝在 Mac OS Catalina 上安装 libxml-ruby 3.1.0



我已经找到了如何使用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 做它应该做的事情。

对于为什么捆绑器在这里失败,没有很好的答案。宝石安装线工作。捆绑器失败。

在 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 不会尊重我经过的路径,所以我查看了它正在寻找xmlversion.h的路径。

我进入了/usr/local/include.这就是我所有自制链接的地方。我创建了一个指向Mac OS提供的libxml目录的符号链接:

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

对于系统目录来说,/usr/local/opt似乎是一个奇怪的地方,但我厌倦了弄乱它。

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

最新更新