我已经找到了如何使用libxml-ruby
命令安装gem install
的所有答案:
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
这应该起作用,对吧?好吧,不是的。我死在水里,直到让邦德勒去做它应该做的事。
对于为什么邦德勒在这里失败,没有很好的答案。 gem安装线有效。捆绑器失败。
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
。如果不遵守Bundle config命令,我不知道如何使Bundler看起来在正确的位置。
由于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
。因此它至少跳过了这一障碍。