使用 rspec 时出错,安装 Homebrew 并卸载 MacPorts 后缺少库

发布于 2024-11-02 19:14:36 字数 989 浏览 1 评论 0原文

我可能迈出了超出我知识范围的一步。我安装了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

帅冕 2024-11-09 19:14:36

我让所有感兴趣的人都重新开始工作。我删除并重新安装了 nokogiri gem,一切似乎都恢复正常了。

I got things working again for anyone interested. I removed and re-installed nokogiri gem and everything seems to be working again.

人心善变 2024-11-09 19:14:36

一般来说,这个问题是因为找不到正确的libiconv造成的。以下是我解决问题的方法:

检查 otool -L /usr/lib/libiconv.2.dylib 的输出。我得到以下输出:

/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

然后我使用 Homebrew 安装 libiconv,brew install libiconv,并使用 brew list libiconv 显示它的安装位置。我得到以下输出:

/usr/local/Cellar/libiconv/1.14/bin/iconv
/usr/local/Cellar/libiconv/1.14/include/ (3 files)
/usr/local/Cellar/libiconv/1.14/lib/libcharset.1.dylib
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
/usr/local/Cellar/libiconv/1.14/lib/ (3 other files)
/usr/local/Cellar/libiconv/1.14/share/doc/ (6 files)
/usr/local/Cellar/libiconv/1.14/share/man/ (6 files)

libiconv 安装在 /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib 中。然后我检查新安装的 libiconv 的版本,
otool -L /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib,我得到以下输出:

/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib:
/usr/local/opt/libiconv/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

版本正确,我们需要使该库可用于Ruby。创建符号链接是一个快速的解决方案:

sudo ln -s /usr/local/opt/libiconv/lib/libiconv.2.dylib /opt/local/lib/libiconv.2.dylib

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:

/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Then I install libiconv with Homebrew, brew install libiconv, and show where it was installed using brew list libiconv. I got the following output:

/usr/local/Cellar/libiconv/1.14/bin/iconv
/usr/local/Cellar/libiconv/1.14/include/ (3 files)
/usr/local/Cellar/libiconv/1.14/lib/libcharset.1.dylib
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
/usr/local/Cellar/libiconv/1.14/lib/ (3 other files)
/usr/local/Cellar/libiconv/1.14/share/doc/ (6 files)
/usr/local/Cellar/libiconv/1.14/share/man/ (6 files)

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:

/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib:
/usr/local/opt/libiconv/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

The version is correct, and we need to make this library available for Ruby. Creating a symbol link is a quick solution:

sudo ln -s /usr/local/opt/libiconv/lib/libiconv.2.dylib /opt/local/lib/libiconv.2.dylib
智商已欠费 2024-11-09 19:14:36

除了 nokogiri 之外,我还必须重新安装 libxml-ruby 才能使一切再次正常运行。

I had to re-install libxml-ruby in addition to nokogiri to get things working again.

长不大的小祸害 2024-11-09 19:14:36

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文