未加载库:/usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Posted
技术标签:
【中文标题】未加载库:/usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)【英文标题】:Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError) 【发布时间】:2017-04-01 23:50:03 【问题描述】:我尝试运行我的rails c
,但由于某种原因,我收到此错误:
https://gist.github.com/anonymous/166713e8cde860fb188a8dffb98a1563
ᐅ rails c
Running via Spring preloader in process 6609
/Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/zulhilmi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/zulhilmi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/zulhilmi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/railties-4.2.6/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:123:in `require_command!'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:58:in `console'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/zulhilmi/hello_gold/cws/bin/rails:8:in `<top (required)>'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/zulhilmi/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/zulhilmi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/zulhilmi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>’
我现在该怎么办?
【问题讨论】:
这个问题已经在这里回答过了,看这个链接,***.com/questions/40435824/…我也在我们的slack组里回答过。 【参考方案1】:刚刚使用 homebrew 更新的 readline 重新编译了 ruby 版本,它就像一个魅力。
rbenv install $(rbenv version-name)
【讨论】:
【参考方案2】:这个命令解决了我的问题:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
或
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
我写了一篇关于这个问题的 Gist here。那里也有很多人分享他们的解决方案。
【讨论】:
这听起来很明显,但如果命令不能逐字运行,请将版本更改为预期版本以及目录中最接近的版本。我的机器需要的是第 6 版,而我有的是第 7 版。 对我来说,我不得不改变一点 -ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
也可以是一个解决方案
有什么解释吗?
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
我认为您需要检查在/usr/local/opt/readline/lib
安装了哪个,然后将其链接到libreadline.6.dylib
。就我而言,我需要将 6 链接到 8。在答案中 @Zulhilmi 将 6 链接到 7。【参考方案3】:
我遇到了同样的根本问题,这也是在 Mac OSX 更新后发生的。我的问题是使用 psql 表现出来的:
>> psql --help
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
Referenced from: /usr/local/bin/psql
Reason: image not found
好的,所以这告诉我它在/usr/local/opt/readline/lib
中期待libreadline.7.dylib
。当我浏览那个目录时,我可以看到我有libreadline.8.0.dylib
:
>> ls -l /usr/local/opt/readline/lib
total 1448
libhistory.8.0.dylib
libhistory.8.dylib -> libhistory.8.0.dylib
libhistory.a
libhistory.dylib -> libhistory.8.0.dylib
libreadline.8.0.dylib
libreadline.8.dylib -> libreadline.8.0.dylib
libreadline.a
libreadline.dylib -> libreadline.8.0.dylib
我假设通过使用符号链接到 libreadline.8.0.dylib
来模拟 libreadline.7.dylib
可以解决我的问题:
>> ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
这使我对psql
的调用再次起作用,但并未解决问题最初是如何开始的。
【讨论】:
【参考方案4】:只需重新安装 ruby 2.3.0 即可解决我在 macos 上的问题
我使用 rbenv
rbenv install 2.3.0
成功了
【讨论】:
【参考方案5】:我重新安装了相同版本的 ruby。然后错误消息现在消失了。我使用 macbook 和自制软件。
$ rbenv install 2.3.8
rbenv: /Users/klee/.rbenv/versions/2.3.8 already exists
continue with installation? (y/N) y
ruby-build: use openssl from homebrew
Downloading ruby-2.3.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.8.tar.bz2
Installing ruby-2.3.8...
ruby-build: use readline from homebrew
Installed ruby-2.3.8 to /Users/klee/.rbenv/versions/2.3.8
【讨论】:
在2.1.10
上发生在我身上。通过重新安装修复。
这似乎是正确的方法(比假设库的 v8 与 v7 兼容更好)。对于 rvm:rvm reinstall ruby-2.6.2
【参考方案6】:
在我的情况下,readline 已安装,但在 MacOS 迁移后未链接。这个命令修复了它:
brew link --force readline
【讨论】:
【参考方案7】:我遇到了同样类型的问题,但这是由于我的 awk 与 gawk 相关联导致使用了错误的库
这对我有用
brew unlink gawk
【讨论】:
【参考方案8】:将此 gem 添加到您的 Gemfile 并运行 bundle install
:
gem 'rb-readline'
【讨论】:
Gem 是在 ruby 中实现 readline 而不是 C,这可能不太好。 效果很好。权宜之计但保守。没有可以忘记的符号链接,也没有可能造成其他问题的安装。以上是关于未加载库:/usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)的主要内容,如果未能解决你的问题,请参考以下文章
应用程序崩溃 - 未加载 AuthenticationServices 库