当我执行 ruby 脚本时,出现以下错误。该脚本使用“nokogiri”。似乎从“/Users/XXX/.bundler/tmp/...”中搜索“libxml2.2.dylib”,但该库实际上位于“/usr/local/Cellar/libxml2/2.9.0/lib/libxml2”中.2.dylib'。
搜索到的目录(/Users/XXX/.bundler/tmp/10029/)不存在。
ruby test.rb
/Users/XXX/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': dlopen(/Users/XXX/.rvm/gems/ruby-1.9.3-p392
/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/XXX/.bundler/tmp/10029/gems/nokogiri-1.6.0/ports/i686-apple-d
arwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/XXX/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/yus
aku/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
如何更改库搜索路径?
我遵循了“Nokogiri”的官方安装(自制 0.9) http://nokogiri.org/tutorials/installing_nokogiri.html
brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2/
--with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/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
任何建议或至少方向将不胜感激。