可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I've just updated to OS X Mountain Lion and I'm getting the following when working with rails and terminal.
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
I've had a look at other answers to a similar question, but they doesn't seem to stop the warning message from appearing.
回答1:
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.
回答2:
I was having similar issues installing nokogiri gem on ruby 1.9.2
Apparently Apple upgraded gcc... I fixed this with a symlink and then the gem installed just fine:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
回答3:
Passing flags to install gems is generally a bad idea if you've got a Gemfile and are using bundler. Even if you're not, you'll be on a custom-compiled libxml and you probably won't remember...! I started by hacking around trying to get this to work and even brew installing libxml2.
Turns out, if you reinstall (and therefore recompile) the ruby version you're working with (hopefully with rvm), it'll work.
So, for RVM users:
rvm list (gets your rubies - choose the one being used)
rvm uninstall RUBY_VERSION
rvm install SAME_RUBY_VERSION
bundle (or gem install nokogiri)
It did the trick for me.
回答4:
Using Ruby 1.9.3-p194 and Rails 3.2.11 on OS X 10.8.2 (Mountain Lion), starting rails c gave the warning:
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
The uninstall/install nokogiri trick didn't work for me. The solution was much simpler...
The warning was avoided completely by editing the Gemifile to place 'nokogiri' above 'pg'.
References:
- https://github.com/sparklemotion/nokogiri/issues/742
- http://www.alanmaciel.net/?p=104
回答5:
all the solution listed so far in here didn't work for me.
So, I did a brew uninstall libxml2
it was the version libxml2 2.8.0
and i guess my os x has libxml2 version 2.7.8 pre-installed
then i did gem uninstall nokogiri
and then gem install nokogiri
Warning is gone now.
But it's libxml2 version 2.7.8 and not the latest. So, I appreciate, if you suggest some solution that work with latest version of libxml2.
回答6:
I just had this problem.
My problem was solved surprisingly easily.
gem uninstall nokogiri
Selected all versions
Then gem install nokogiri
and it went away.
if you are using home-brew, you can brew update
and brew doctor
. Upgrading to mountain lion even removed my git and stuff. I installed it back by installing cc tools in Xcode and using brew doctor to make sure it's raring to go
before the above.
回答7:
So I ended up using the following command:
bundle config build.nokogiri --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26/
And then doing:
gem uninstall nokogiri
gem install nokogiri
And then ran
bundle install
回答8:
Nothing seemed to work for me to fix this one.
Then I went into xcode and installed the updated command line tools, then gem uninstall nokogiri
and gem install nokogiri
and it worked!
回答9:
After upgrading ruby-build
brew update
brew upgrade ruby-build
I just reinstalled ruby (last version)
rbenv install 1.9.3-p194
and then I installed all the gems related to my project including nokogiri without having further problems.
gem install bundler
bundle