How Do I Correct An Error with rails console comma

2019-06-27 00:19发布

问题:

When I'm in the root directory of my Rails app I can successfully execute rails server. However when I try to do rails console or rails c I get the following error.

[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>'

I have done web searches but I have not found any solutions for this type of error.

回答1:

brew rm -f readline

brew install readline

brew link readline --force

Reference link: rails console doesn't load due to libreadline



回答2:

In my case a reinstall with rvm fixed the error

rvm reinstall 2.3.0


回答3:

edit: ok run this

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

to remove dir from old references