在小牛升级后安装nokogiri - entities.c失踪了吗?

时间:2014-04-26 21:43:59

标签: nokogiri osx-mavericks

我遇到了同样的问题,大多数人在后小牛升级机上使用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

我的configure.log显示以下错误:

configure: error: cannot find sources (entities.c) in /usr/local/lib/node_modules/npm or ..

我已尝试安装/重新安装/取消链接/重新链接libxml2,libxslt。

还有其他提示吗?谢谢!

3 个答案:

答案 0 :(得分:6)

使用Homebrew安装库并在安装gem之前设置NOKOGIRI_USE_SYSTEM_LIBRARIES=1对我来说很有用。

汇总:

  • 如果以前安装过,请卸载gem:
    $ gem uninstall nokogiri

  • 使用Homebrew安装libxml2libxsltlibiconv
    $ 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"

答案 1 :(得分:1)

有完全相同的问题。我锁定了它为什么在

中寻找(entities.c)
/usr/local/lib/node_modules/npm or ..

我不是专家,但是npm可能没有make文件。

我通过从〜/ .bash_profile删除npm来安装nokogiri(另一个要检查的地方可能是〜/ .profile)。这是我的.bash_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 install nokogiri和IT工作:)!!!

作为旁注,npm命令似乎正在工作,所以我不知道为什么我在.bash_profile中有这条路径

希望这有帮助,首先回答SO。

答案 2 :(得分:0)

这是我通过brew安装Yosemite和libxml2的解决方案

gem install nokogiri -v '1.6.5' -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2