库未加载:/usr/local/opt/readline/lib/libreadline.6.dylib(LoadError)


78

我尝试运行我的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>’

我现在应该怎么办?


这个问题已经在这里得到了回答,请参阅此链接,stackoverflow.com/ questions/ 40435824/…我也在我们的闲暇小组中回答了它。
肖恩·威尔逊

Answers:


239

这个命令解决了我的问题:

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

在这里写了关于这个问题的要点。那里也有很多人分享他们的解决方案。


5
这听起来似乎很明显,但是如果命令不能逐字运行,请将版本更改为预期版本以及目录中最接近的版本。我的机器在期待第6版,我不得不版本7
user478798

1
对我来说,我不得不改变一下ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
Huzaifa Saifuddin

38
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib也可以是一个解决方案
okliv

1
有什么解释吗?
YasirAzgar '19

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。– wuliwong

63

将此gem添加到您的Gemfile并运行bundle install

gem 'rb-readline'

宝石是红宝石中的readline的实现,而不是C,这可能不太好。
柯里尔·普莱什凯维奇

1
很棒。权宜而又保守。没有符号链接可以忘记,也没有安装可能引起其他问题的安装。
hawmack13

18

我有同样的潜在问题,在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

好的,所以这告诉我期望libreadline.7.dylib在中/usr/local/opt/readline/lib。当我浏览该目录时,我可以看到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.7.dylib使用符号链接进行仿真libreadline.8.0.dylib可以解决我的问题:

>> ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

这使我的电话psql再次工作,但一开始并没有解决问题的开始方式。


4

我再次安装了相同版本的红宝石。然后错误消息消失了。我使用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。通过重新安装修复。
Jagdeep Singh

这似乎是正确的方法(比假设库的v8与v7兼容更好)。对于rvm:rvm reinstall ruby-2.6.2
jwadsa​​ck,

3

只需使用自制软件更新的readline重新编译红宝石版本,它的工作原理就像一个魅力。

rbenv install $(rbenv version-name)

2

我遇到了相同类型的问题,但这是由于我的awk与gawk相关联导致使用错误的lib

这对我有用

brew unlink gawk


0

在我的情况下,在MacOS迁移后已安装readline,但未链接。此命令修复了该问题:

brew link --force readline

0

只需重新安装ruby 2.3.0即可在macOS上解决我的问题,我使用rbenv rbenv install 2.3.0做到了

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.