Library not loaded: /usr/local/opt/readline/lib/li

2020-05-14 13:28发布

I try to run my rails c but for some reason, I get this error:

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?

8条回答
放我归山
2楼-- · 2020-05-14 13:47

In my case readline was installed but not linked after a MacOS migration. This command fixed it:

brew link --force readline
查看更多
可以哭但决不认输i
3楼-- · 2020-05-14 13:56

I had the same underlying issue, which also occurred after a Mac OSX update. My problem manifested using 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.dylib in /usr/local/opt/readline/lib. When I browse that directory, I can see I have 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.dylib by using symlinking to libreadline.8.0.dylib could resolve my problem:

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

Which makes my call to psql work again, but doesn't address how the problem started in the first place.

查看更多
贪生不怕死
4楼-- · 2020-05-14 13:59

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.

查看更多
何必那么认真
5楼-- · 2020-05-14 14:01

simply reinstalling ruby 2.3.0 fixed my problem on macos I use rbenv rbenv install 2.3.0 did the trick

查看更多
虎瘦雄心在
6楼-- · 2020-05-14 14:03

Add this gem to your Gemfile and run bundle install:

gem 'rb-readline'
查看更多
▲ chillily
7楼-- · 2020-05-14 14:04

Just recompiled ruby version using updated readline from homebrew and it works like a charm.

rbenv install $(rbenv version-name)
查看更多
登录 后发表回答