简体   繁体   English

山狮 - LibXML和Nokogiri

[英]Mountain Lion - LibXML & Nokogiri

I've just updated to OS X Mountain Lion and I'm getting the following when working with rails and terminal. 我刚刚更新到OS X Mountain Lion,在使用rails和终端时我得到了以下内容。

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. 我已经看过类似问题的其他答案,但它们似乎并没有阻止出现警告信息。

我在ruby 1.9.2上安装nokogiri gem时遇到了类似的问题。显然Apple升级了gcc ......我用符号链接修复了这个问题,然后将gem安装得很好:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

Putting gem 'nokogiri' above gem 'pg' in my Gemfile fixed this for me. 在我的Gemfile gem 'nokogiri'放在gem 'pg'之上为我修复了这个问题。

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. 我的Gemfile中没有nokogiri,但它是Gemfile.lock中的依赖项,所以我明确地将它放在我的Gemfile中。

Passing flags to install gems is generally a bad idea if you've got a Gemfile and are using bundler. 如果你有一个Gemfile并且正在使用bundler,那么传递标志来安装gem通常是一个坏主意。 Even if you're not, you'll be on a custom-compiled libxml and you probably won't remember...! 即使你不是,你也会使用自定义编译的libxml,你可能不会记得......! I started by hacking around trying to get this to work and even brew installing libxml2. 我开始讨厌尝试让它工作,甚至酿造安装libxml2。

Turns out, if you reinstall (and therefore recompile) the ruby version you're working with (hopefully with rvm), it'll work. 事实证明,如果您重新安装(并因此重新编译)您正在使用的ruby版本(希望使用rvm),它将起作用。

So, for RVM users: 因此,对于RVM用户:

    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. 它为我做了伎俩。

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: 在OS X 10.8.2(Mountain Lion)上使用Ruby 1.9.3-p194和Rails 3.2.11,启动rails c发出警告:

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. 卸载/安装nokogiri技巧对我不起作用。 The solution was much simpler... The warning was avoided completely by editing the Gemifile to place 'nokogiri' above 'pg'. 解决方案简单得多......通过编辑Gemifile将'nokogiri'置于'pg'之上,完全避免了警告。

References: 参考文献:

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 所以,我做了一个brew uninstall libxml2它的版本是libxml2 2.8.0而且我猜我的os x已预先安装了libxml2版本2.7.8

then i did gem uninstall nokogiri and then gem install nokogiri 然后我做了gem uninstall nokogiri然后gem install nokogiri

Warning is gone now. 警告现在消失了。 But it's libxml2 version 2.7.8 and not the latest. 但它是libxml2版本2.7.8而不是最新版本。 So, I appreciate, if you suggest some solution that work with latest version of libxml2. 所以,我很感激,如果你建议一些解决方案适用于最新版本的libxml2。

I just had this problem. 我刚遇到这个问题。

My problem was solved surprisingly easily. 我的问题很容易解决。

gem uninstall nokogiri

Selected all versions 选择all versions

Then gem install nokogiri and it went away. 然后gem install nokogiri ,它消失了。

if you are using home-brew, you can brew update and brew doctor . 如果你正在使用家庭酿造,你可以brew updatebrew doctor Upgrading to mountain lion even removed my git and stuff. 升级到山狮甚至取消了我的git和东西。 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. 我安装了它回来在Xcode安装CC工具和使用BREW医生,以确保它的raring to go上面了。

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

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! 然后我进入xcode并安装了更新的命令行工具,然后gem uninstall nokogirigem install nokogiri ,它工作了!

After upgrading ruby-build 升级后的ruby-build

brew update
brew upgrade ruby-build

I just reinstalled ruby (last version) 我刚刚重新安装了ruby(最新版本)

rbenv install 1.9.3-p194

and then I installed all the gems related to my project including nokogiri without having further problems. 然后我安装了与我的项目相关的所有宝石,包括nokogiri而没有进一步的问题。

gem install bundler
bundle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM