Ruby-on-rails 库未加载:/usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40671803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
提问by Zulhilmi Zainudin
I try to run my rails cbut for some reason, I get this error:
我尝试运行我的rails c但由于某种原因,我收到此错误:
https://gist.github.com/anonymous/166713e8cde860fb188a8dffb98a1563
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>'
What should I do now?
我现在该怎么办?
回答by Zulhilmi Zainudin
This command fix my problem:
此命令解决了我的问题:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
OR
或者
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
I wrote a Gist about this problem here. There are many people sharing their solutions there too.
我在这里写了一个关于这个问题的要点。还有很多人在那里分享他们的解决方案。
回答by zee
Add this gem to your Gemfile and run bundle install:
将此 gem 添加到您的 Gemfile 并运行bundle install:
gem 'rb-readline'
回答by Christopher Compeau
I had the same underlying issue, which also occurred after a Mac OSX update. My problem manifested using psql:
我有同样的潜在问题,这也发生在 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
OK, so this is telling me that it's expecting libreadline.7.dylibin /usr/local/opt/readline/lib. When I browse that directory, I can see I have libreadline.8.0.dylib:
好的,所以这告诉我它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
I made the assumption that emulating libreadline.7.dylibby using symlinking to libreadline.8.0.dylibcould resolve my problem:
我假设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
Which makes my call to psqlwork again, but doesn't address how the problem started in the first place.
这使我psql再次呼吁工作,但并没有解决问题最初是如何开始的。
回答by kangkyu
I installed the ruby of same version over again. Then the error message is gone now. I use macbook and homebrew.
我再次安装了相同版本的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
回答by Kiryl Plyashkevich
Just recompiled ruby version using updated readline from homebrew and it works like a charm.
刚刚使用来自自制软件的更新的 readline 重新编译了 ruby 版本,它就像一个魅力。
rbenv install $(rbenv version-name)
回答by Scott
i was having the same type of issue but it was due to the fact that my awk was linked to gawk leading to using the wrong lib
我遇到了同样类型的问题,但这是因为我的 awk 与 gawk 相关联,导致使用了错误的库
this worked for me
这对我有用
brew unlink gawk
brew unlink gawk
回答by Gus
In my case readlinewas installed but not linked after a MacOS migration. This command fixed it:
在我的情况下,在 MacOS 迁移后安装了readline但未链接。这个命令修复了它:
brew link --force readline
回答by Sathish
simply reinstalling ruby 2.3.0 fixed my problem on macos
I use rbenv
rbenv install 2.3.0did the trick
只需重新安装红宝石2.3.0固定在MacOS我的问题,我用rbenv
rbenv install 2.3.0的伎俩

