当我在我的Rails应用程序的根目录中时,我可以成功执行rails server
。但是,当我尝试rails console
或rails c
时,我收到以下错误。
[myrailsapp (master)]$ rails c
/Users/myuserid/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `require': dlopen(/Users/myuserid/.rvm/rubies/ruby-2.3.0/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/myuserid/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/myuserid/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/myuserid/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands/console.rb:3:in `require'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:123:in `require'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:123:in `require_command!'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:58:in `console'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/myuserid/.rvm/gems/ruby-2.3.0@mygemset/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我已完成网络搜索,但我没有找到任何解决此类错误的方法。
答案 0 :(得分:5)
brew rm -f readline
brew install readline
brew link readline --force
答案 1 :(得分:3)
在我的情况下,使用rvm重新安装修复了错误
rvm reinstall 2.3.0
答案 2 :(得分:0)
编辑:确定运行此
sudo install_name_tool -change libreadline.6.dylib
/usr/local/opt/readline/lib/libreadline.6.dylib
/Users/myuserid/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
sudo install_name_tool -change libreadline.6.dylib
/usr/local/opt/readline/lib/libreadline.6.dylib
/Users/myuserid/.rvm/rubies/ruby-2.3.0/ruby/2.3.0/x86_64-darwin15/readline.bundle
从旧引用中删除目录