我遇到了大多数人在小牛队升级后的机器上安装nokogiri时遇到的同样问题。
/Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libx/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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
--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/lunchbag/.rvm/rubies/ruby-2.0.0-p451/bin/ruby
/Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:278:in `block in execute': Failed to complete configure task (RuntimeError)
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:270:in `chdir'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:270:in `execute'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:65:in `configure'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:108:in `cook'
from extconf.rb:101:in `block in <main>'
from extconf.rb:119:in `call'
from extconf.rb:119:in `block in <main>'
from extconf.rb:109:in `tap'
from extconf.rb:109:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/lunchbag/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/lunchbag/.rvm/gems/ruby-2.0.0-p451/extensions/x86_64-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out
我的config.log显示以下错误:
configure: error: cannot find sources (entities.c) in /usr/local/lib/node_modules/npm or ..
我尝试过安装/重新安装/取消链接/重新链接libxml2、libxslt。
还有其他建议吗?谢谢
用Homebrew安装库并在安装gem之前设置NOKOGIRI_USE_SYSTEM_LIBRARIES=1
对我来说很有用。
总结:
-
如果以前安装过,请卸载gem:
$ gem uninstall nokogiri
-
使用Homebrew安装
libxml2
、libxslt
和libiconv
:$ brew install libxml2 libxslt libiconv
-
安装gem,指定要链接的库的路径:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
也有同样的问题。我明白了为什么它在中寻找(实体.c)
/usr/local/lib/node_modules/npm or ..
我不是专家,但npm可能没有制作文件。
我通过从我的~/.bash_profile中删除npm来安装nokogiri(另一个要检查的地方可能是~/.profile)
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib/node_modules/npm:/usr/local/mysql/bin:$PATH"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
source ~/.profile
你可以在第一行看到npm,我刚刚删除了它,重新加载了我的终端(所以它停止在npm目录中查找东西),并安装了sudo gem nokogiri和它工作:)!!!
顺便说一句,npm命令似乎正在工作,所以我不知道为什么我的.bash_profile 中有这个路径
希望这有帮助,首先回答SO.
这是我通过brew 安装的Yosemite和libxml2的解决方案
gem install nokogiri -v '1.6.5' -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2