rails c not working in rails 5
Asked Answered
P

5

15

On using the command in terminal inside a rails 5 application

rails c

the error thrown is given bellow. I have no idea what this means in a similar question here that for which the solution was to use spring stop. I have tried that too but no it still gave the same error. it would be great if somebody can point out the mistake here.

Running via Spring preloader in process 6457
/Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': dlopen(/Users/AmanChawla/.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/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `<top (required)>'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
    from /Users/AmanChawla/Desktop/NewApp/bin/rails:9:in `<top (required)>'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/AmanChawla/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
    from /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/AmanChawla/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'
Permatron answered 5/11, 2016 at 7:26 Comment(6)
Have you updated HomeBrew? and / Or Have you updates to Mac OSX Sierra? This error is most likely caused from updating homebrew as it has been patched for SierraFrantz
Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib is the issueFrantz
How do i fix this?Permatron
i need to know what you have updatedFrantz
Please check my answer(accepted) here #37739434Attribute
Read my answer. Try it before you start messing with soft-links and other suggested answers.Academe
E
36

I recently had this problem when I updated HomeBrew, I'm also working with rails 5 and found this solution and it worked for me:

ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

Source: https://gist.github.com/mcshakes/c87e8adda174c73be354094800b9756d

UPDATE

For readline 8 and newer versions, follow the answer given by @Cody Elhard

Epilepsy answered 5/11, 2016 at 7:36 Comment(4)
Works! Ruby 2.5.0, Rails 5.1.4 os/xHildie
Or it could be: ln -s /usr/local/opt/readline/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylibShoplifter
If you have readline 8 you will need to do ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylibEclat
Can this be considered a fix? Fixing a pointer to non-existent file by mimicking that file hardly seems like a solution. Rather a quick patch. Is there a way to make it point to the correct file?Alkalosis
L
22

As a general approach if this error occurred due to updating readline with homebrew

New version can be found by reading the output of brew install readline

My output: readline 8.0.0 is already installed and up-to-date

Old version can be found by load error

My error (Note the 7): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)

ln -s new_version/path/to/readline original_version/path/to/readline

In my case my command was

ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
Littleton answered 16/1, 2019 at 14:10 Comment(3)
Worked for me after a strange bug with my Macbook, thanksSchaper
My symptoms started showing up after a brew cleanup. This solved it!Cucullate
Thank you so much for explaining how to think this through. That worked perfectly for me.Pubis
A
10

I fixed this issue by simply adding this gem gem 'rb-readline' and running bundle.

rb-readline

Academe answered 26/7, 2017 at 18:8 Comment(0)
F
2

This is a standard fix to this issue try this.. It should get you going

brew rm -f readline

brew install readline

brew link readline --force

here is a reference link rails console doesn't load due to libreadline

Frantz answered 5/11, 2016 at 7:35 Comment(0)
M
0

Another issue might be which version of ruby is in your path - double check that as well.

ruby -v
ls -la `which ruby`

then check your PATH

Mycobacterium answered 25/7, 2017 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.