WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8

时光怂恿深爱的人放手 提交于 2019-11-27 20:37:06

I reinstalled Ruby, that fixed it. Was able to use the built-in libraries.

I have found some fixes for Lion, but none for Mountain Lion yet. Nonetheless I have tried this and it works:

gem uninstall nokogiri libxml-ruby

brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link libxml2

brew install libxslt
brew link libxslt

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2/ --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib/ --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26/

Source (for Lion): https://gist.github.com/1349681

gem uninstall nokogiri
bundle install

Even Better:

gem pristine nokogiri

Note:

This will happen repeatedly as you upgrade your system and libraries change.

Note that linking as in @Davids post will interfere with your build tools and link into your OS (which is most likely not what you want if you're using brew), but you can just execute each command above except omit the 'brew link' lines and everything will still build just fine, eg:

gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew install libxslt

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2/ --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib/ --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26/

Putting gem 'nokogiri' above gem 'pg' in my Gemfile fixed this for me.

My Gemfile didn't have nokogiri in it, but it was a dependency that was in Gemfile.lock, so I put it in my Gemfile explicitly.

Based on the answer from @David the following steps were enough for me. No compiler flags and custom paths.

gem uninstall nokogiri

brew update
brew install libxml2
brew update libxml2
brew link libxml2

gem install nokogiri
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!