警告:Nokogiri是针对LibXML版本2.7.7构建的,但动态加载了2.6.16

时间:2011-02-07 07:51:23

标签: compilation ruby-on-rails rvm

当我启动Rails时,我无法理解为什么我从Nokogiri那里得到这个错误。从我知道的一点点来看,似乎有些东西导致加载旧版本的libxml2,Nokogiri最终会使用它,而不是它编译的版本。

如果没有警告(并使用正确的libxml2),我需要做些什么才能使用?

我在运行OS X 10.5.8的Macbook上运行它:

$ rake db:create
(in /Users/gareth/Sites/Rails3/ngtest)
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.6.16
HI.  You're using libxml2 version 2.6.16 which is over 4 years old and has
plenty of bugs.  We suggest that for maximum HTML/XML parsing pleasure, you
upgrade your version of libxml2 and re-install nokogiri.  If you like using
libxml2 version 2.6.16, but don't like this warning, please define the constant
I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2 before requring nokogiri.

ngtest_test already exists
ngtest_development already exists

$ DYLD_PRINT_LIBRARIES=1 rake db:create
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/libruby.1.9.1.dylib
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/libobjc.A.dylib
dyld: loaded: /usr/lib/libgcc_s.1.dylib
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib
dyld: loaded: /usr/lib/libauto.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/encdb.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/trans/transdb.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/etc.bundle
(in /Users/gareth/Sites/Rails3/ngtest)
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/stringio.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/syck.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/digest/sha1.bundle
dyld: loaded: /usr/lib/libcrypto.0.9.7.dylib
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/digest.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/iso_8859_1.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/zlib.bundle
dyld: loaded: /usr/lib/libz.1.dylib
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/strscan.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/bigdecimal.bundle
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/mysql-2.8.1/lib/mysql_api.bundle
dyld: loaded: /usr/local/Cellar/mysql/5.1.54/lib/mysql/libmysqlclient.16.dylib
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/openssl.bundle
dyld: loaded: /usr/lib/libssl.0.9.7.dylib
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/fcntl.bundle
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/eventmachine-0.12.10/lib/rubyeventmachine.bundle
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/thin-1.2.7/lib/thin_parser.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/digest/md5.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/iconv.bundle
dyld: loaded: /usr/lib/libiconv.2.dylib
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/json-1.4.6/ext/json/ext/json/ext/parser.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/utf_16be.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/utf_16le.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/utf_32be.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/enc/utf_32le.bundle
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/json-1.4.6/ext/json/ext/json/ext/generator.bundle
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/rpeg-markdown-1.4.6/lib/peg_markdown.bundle
dyld: loaded: /usr/local/Cellar/glib/2.24.2/lib/libglib-2.0.0.dylib
dyld: loaded: /usr/local/Cellar/gettext/0.17/lib/libintl.8.dylib
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
dyld: loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/CarbonSound
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/NavigationServices.framework/Versions/A/NavigationServices
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
dyld: loaded: /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
dyld: loaded: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
dyld: loaded: /usr/lib/libicucore.A.dylib
dyld: loaded: /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
dyld: loaded: /usr/lib/libbsm.dylib
dyld: loaded: /System/Library/Frameworks/Security.framework/Versions/A/Security
dyld: loaded: /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
dyld: loaded: /usr/lib/libsqlite3.0.dylib
dyld: loaded: /usr/lib/libresolv.9.dylib
dyld: loaded: /usr/lib/libxml2.2.dylib
dyld: loaded: /usr/lib/libxslt.1.dylib
dyld: loaded: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
dyld: loaded: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
dyld: loaded: /usr/lib/libcups.2.dylib
dyld: loaded: /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
dyld: loaded: /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
dyld: loaded: /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
dyld: loaded: /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
dyld: loaded: /usr/lib/libffi.dylib
dyld: loaded: /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
dyld: loaded: /System/Library/PrivateFrameworks/InstallServer.framework/Versions/A/InstallServer
dyld: loaded: /Users/gareth/.rvm/gems/ruby-1.9.2-p136/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
dyld: loaded: /usr/local/Cellar/libxslt/1.1.26/lib/libexslt.0.dylib
dyld: loaded: /usr/local/Cellar/libxslt/1.1.26/lib/libxslt.1.dylib
dyld: loaded: /usr/local/Cellar/libxml2/2.7.7/lib/libxml2.2.dylib
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.6.16
HI.  You're using libxml2 version 2.6.16 which is over 4 years old and has
plenty of bugs.  We suggest that for maximum HTML/XML parsing pleasure, you
upgrade your version of libxml2 and re-install nokogiri.  If you like using
libxml2 version 2.6.16, but don't like this warning, please define the constant
I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2 before requring nokogiri.

dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/racc/cparse.bundle
dyld: loaded: /Users/gareth/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/i386-darwin9.8.0/socket.bundle
ngtest_test already exists
ngtest_development already exists

$ nokogiri -v
--- 
warnings: []

nokogiri: 1.4.4
ruby: 
  version: 1.9.2
  platform: i386-darwin9.8.0
  engine: ruby
libxml: 
  binding: extension
  compiled: 2.7.7
  loaded: 2.7.7

8 个答案:

答案 0 :(得分:33)

最后,我必须针对我已安装的xml2xslt的特定版本安装gem:

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
#. scrollbar line, so the code can be seen

问题很可能是糟糕的图书馆管理,在包管理人之间进行切换而不是很整洁。

答案 1 :(得分:23)

修复Nokogiri w。 libxml2 2.7.8加载libxml2 2.7.3

想要加上以上答案: 如果你在OSX上的Cellar目录中没有libxml2,你可以使用自制程序将其安装到此,如Nokogiri的主页(自制的0.8或更高版本,使用brew -v测试)所述:

brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri -- --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include

答案 2 :(得分:17)

我有一个不同的警告:

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

使用较新的库重建gem以消除警告:

gem install --no-rdoc --no-ri nokogiri -- --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib

答案 3 :(得分:6)

接受的解决方案对我不起作用,但确实如此:

gem install --no-rdoc --no-ri nokogiri -- --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib

这针对MacOS系统库进行编译。不过,我的机器上可能没有正确设置Macports(我更喜欢冲泡)。

答案 4 :(得分:3)

Nokogiri构建正确,但首先需要另一个gem并加载旧的libxml2库。

在你的应用程序中,你应首先要求nokogiri,强制应用程序加载动态libxml2库,而不是由未能指定要加载哪个库的gem加载的旧系统版本的libxml2。

答案 5 :(得分:1)

确保它不仅仅是ruby编译问题。这刚刚出现在OSX Mountain Lion上,因为系统libxml被撞了,但ruby是在之前的libxml上编译的。它可以通过卸载并重新安装ruby来解决。

我在另一个帖子上的答案供参考: https://stackoverflow.com/a/11714789/1561677

答案 6 :(得分:0)

我曾经有类似的问题,你真的需要在你的系统上使用两个版本的libxml吗? 否则,卸载所有旧版本的libxml,以防强制重新安装nokogiri。

答案 7 :(得分:0)

我遇到了同样的问题。我所做的只是在我的Gemfile中添加一行以明确要求最新版本的nokogiri(截至2013年3月17日,1.5.6),然后我做了bundle update nokogiri,它修复了问题。 / p>