How Do I Correct An Error with rails console command?
Asked Answered
A

3

4

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.

Anthroposophy answered 10/6, 2016 at 2:16 Comment(2)
Check the answer from #25592027Caddy
Add this as an answer and I will upcheck it.Anthroposophy
C
5

brew rm -f readline

brew install readline

brew link readline --force

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

Caddy answered 10/6, 2016 at 2:40 Comment(2)
Thanks! I did this and was able to execute the rails console as before.Anthroposophy
@FilipBartuzi When in doubt, you force ;)Cathee
S
3

In my case a reinstall with rvm fixed the error

rvm reinstall 2.3.0
Snowstorm answered 11/10, 2016 at 13:6 Comment(0)
S
0

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

Solvency answered 10/6, 2016 at 2:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.