使用 rspec 时出错,安装 Homebrew 并卸载 MacPorts 后缺少库
我可能迈出了超出我知识范围的一步。我安装了Homebrew,之后它继续向我发出有关MacPorts 安装了我卸载了它。但现在我的 rspec 测试无法运行。
这些是我得到的错误:
/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri.rb:13:in `require': dlopen(/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /opt/local/lib/libiconv.2.dylib (LoadError)
Referenced from: /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 - /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
.....
.....
我已经通过 Homebrew 安装了 libiconv,但这并没有解决它。它抱怨 libiconv 版本号。这是问题所在吗?
这是怎么回事?我需要做什么?
I may have taken one step too far beyond my knowledge. I installed Homebrew and after it continued to give me warnings about having MacPorts installed I uninstalled that. But now my rspec tests don't run.
These are the errors I get:
/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri.rb:13:in `require': dlopen(/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /opt/local/lib/libiconv.2.dylib (LoadError)
Referenced from: /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 - /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
.....
.....
I've installed libiconv through Homebrew, but that didn't fix it. It's complaining about libiconv version numbers. Is this the problem?
What is going on here and what do I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我让所有感兴趣的人都重新开始工作。我删除并重新安装了 nokogiri gem,一切似乎都恢复正常了。
I got things working again for anyone interested. I removed and re-installed nokogiri gem and everything seems to be working again.
一般来说,这个问题是因为找不到正确的libiconv造成的。以下是我解决问题的方法:
检查
otool -L /usr/lib/libiconv.2.dylib
的输出。我得到以下输出:然后我使用 Homebrew 安装 libiconv,
brew install libiconv
,并使用brew list libiconv
显示它的安装位置。我得到以下输出:libiconv 安装在
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
中。然后我检查新安装的 libiconv 的版本,otool -L /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
,我得到以下输出:版本正确,我们需要使该库可用于Ruby。创建符号链接是一个快速的解决方案:
Generally, this problem is caused by being unable to find the right libiconv. Here is how I solve my problem:
Check output of
otool -L /usr/lib/libiconv.2.dylib
. I got the following output:Then I install libiconv with Homebrew,
brew install libiconv
, and show where it was installed usingbrew list libiconv
. I got the following output:the libiconv is installed in
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
. Then I check verion of newly installed libiconv,otool -L /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
, and I got the following output:The version is correct, and we need to make this library available for Ruby. Creating a symbol link is a quick solution:
除了 nokogiri 之外,我还必须重新安装 libxml-ruby 才能使一切再次正常运行。
I had to re-install libxml-ruby in addition to nokogiri to get things working again.
FWIW,我遇到了同样的问题,如果您供应您的 gem,则必须从供应商/ruby 中删除有问题的 gem,因为 gem 卸载+重新安装并不总是有效。我猜测即使在运行全新安装时,捆绑程序也会留下宝石及其各自库的缓存残留。
FWIW, I ran into the same issue and if you are vendorizing your gems, you will have to remove the offending gem from vendor/ruby as a gem uninstall + reinstall is not always efficient. I'm guessing bundler leaves cache remnants of gems and their respective libs even when running a fresh install.