18

When trying to start rails console I keep getting the following error

Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/completion.rb:9:in `require': dlopen(/Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle, 9): Library not loaded: /Users/rigelstpierre/.rvm/usr/lib/libreadline.6.2.dylib (LoadError)
  Referenced from: /Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle
  Reason: image not found - /Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle
    from /Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
    from /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.2/lib/rails/commands/console.rb:3:in `require'
    from /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.2/lib/rails/commands/console.rb:3:in `<top (required)>'
    from /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.2/lib/rails/commands.rb:38:in `require'
    from /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.2/lib/rails/commands.rb:38:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Any thoughts? Rails 3.2.2 application

rigelstpierre
  • 534
  • 1
  • 6
  • 22

8 Answers8

25

It could be that there are multiple versions of readline installed.

Try the following:

brew link readline --force
Community
  • 1
  • 1
Ron Crosler
  • 276
  • 3
  • 5
  • 1
    Tried that and still nothing. – rigelstpierre Sep 25 '12 at 23:08
  • Sorry, I was unclear. What did that command return? My suspicion is that there may be an issue with your readline installation. – Ron Crosler Sep 26 '12 at 00:02
  • I went through the blog post, and then ran 'brew link readline' and that created the symlink. '/Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/completion.rb:9:in `require': dlopen(/Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle, 9): Library not loaded: /Users/rigelstpierre/.rvm/usr/lib/libncurses.5.dylib (LoadError) Referenced from: /Users/rigelstpierre/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle Reason: no suitable image found. Did find:' – rigelstpierre Sep 26 '12 at 00:27
  • 5
    I had to do: `brew link readline --force` to make it work. Thank you. – Surya Feb 20 '14 at 06:07
15

I had this couple of days ago. You can try to reinstall/recompile your ruby. In my case problem appeared when updating from El Capitan to Sierra

so depending on your manager:

RVM

rvm reinstall 2.3.0

Rbenv

rbenv uninstall 2.3.0
rbenv install 2.3.0

asdf

asdf uninstall ruby 2.3.0
asdf install ruby 2.3.0
Lukasz Muzyka
  • 2,783
  • 1
  • 30
  • 41
  • No worries. but dude, it took me a looong time to do this. I basically tried other solutions from this page and nothing worked.... – Lukasz Muzyka Oct 19 '16 at 08:56
15

Looking elsewhere, none of the re-linking options worked. It was suggested to redo the rvm installation (which seems onerous). However, simply adding readline into the Gemfile works for me:

gem 'rb-readline'
Joe B.
  • 1,153
  • 1
  • 10
  • 17
12

It is because multiple versions of readline is installed (Could be because you ran brew update recently). What Ron said is right. You can fix it by running brew link readline or brew link readline --force.

If it still doesn't work, find which readline and move to readline folder then delete the version that you don't need (Or the ones that installed by running brew update). Then run brew link readline again.

J. Chomel
  • 8,193
  • 15
  • 41
  • 69
Iran R
  • 131
  • 1
  • 4
  • 4
    this worked, deleted the newer version inside `/usr/local/Cellar/readline`, ran the above command and worked again! – L457 Oct 14 '16 at 00:06
5

For me on macOS sierra, brew link readline or brew link readline --force does not work and I ran brew update recently. But rails console does work after I do as below:

rvm reinstall 2.3.1

张艳军
  • 241
  • 4
  • 5
3

After reinstalling readline, I could still not able to load rails console.

However, reinstalling ruby did it for me.

rvm reinstall 1.9.3

PS: I'm on OSX El Capitan

cnikolaou
  • 3,782
  • 4
  • 25
  • 32
1

On macOS Sierra I was facing the same issue with homebrew and libreadline, I tried to do brew link readline, brew link readline --force and brew update but all in vain, then I found another solution that solved my issue.

There was a linking issue libreadline required by homebrew was unlinked and not able to link by brew commands

Creating a symbolic link solved my issue.

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

Try creating symbolic link. Hope this solves your problem.

Mutafaf
  • 126
  • 3
  • 13
1

In my case, the version numbers of readline were different, and I was missing libreadline.7.dylib. Linking and unlinking using Homebrew didn't help. The following did though:

~$ cd /usr/local/opt/readline/lib
/usr/local/opt/readline/lib$ ls -l
total 1448
-r--r--r--  1 ceasar  staff   40396 Mar 22 11:35 libhistory.8.0.dylib
lrwxr-xr-x  1 ceasar  staff      20 Dec 19 13:07 libhistory.8.dylib -> libhistory.8.0.dylib
-r--r--r--  1 ceasar  staff   45848 Dec 19 13:07 libhistory.a
lrwxr-xr-x  1 ceasar  staff      20 Dec 19 13:07 libhistory.dylib -> libhistory.8.0.dylib
-rw-r--r--  1 ceasar  staff  239260 Mar 22 11:35 libreadline.8.0.dylib
lrwxr-xr-x  1 ceasar  staff      21 Dec 19 13:07 libreadline.8.dylib -> libreadline.8.0.dylib
-r--r--r--  1 ceasar  staff  406384 Dec 19 13:07 libreadline.a
lrwxr-xr-x  1 ceasar  staff      21 Dec 19 13:07 libreadline.dylib -> libreadline.8.0.dylib
drwxr-xr-x  3 ceasar  staff      96 Mar 22 11:35 pkgconfig
/usr/local/opt/readline/lib$ ln -s libreadline.dylib libreadline.7.dylib
Ceasar
  • 22,185
  • 15
  • 64
  • 83