Search code examples
rubyreadlineirb

IRB not loading library libreadline


Tried to get into irb but suddenly started receiving this error. Tried reinstalling brew readline and relinking, but no luck. Any suggestions?

/Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/x86_64-darwin17/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
  Referenced from: /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/x86_64-darwin17/readline.bundle
  Reason: image not found - /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/x86_64-darwin17/readline.bundle
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb/ext/save-history.rb:12:in `<top (required)>'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb/extend-command.rb:243:in `save_history='
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb/context.rb:92:in `initialize'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb.rb:412:in `new'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb.rb:412:in `initialize'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb.rb:383:in `new'
    from /Users/asahmed/.rbenv/versions/2.4.2/lib/ruby/2.4.0/irb.rb:383:in `start'
    from /Users/asahmed/.rbenv/versions/2.4.2/bin/irb:11:in `<main>'

Solution

  • You may have upgraded something that replaced the readline library and it's now necessary to rebuild your Ruby. This sort of thing happens infrequently with Homebrew when you run brew clean and it deletes an obsolete version of a dependency, not realizing one of your Ruby builds depends on it. This is because Rbenv has no way of communicating to Homebrew that it still needs that library.

    This is usually easy to fix. Try:

    rbenv install 2.4.2
    

    You might also want to take the time to update to the latest version which is, as of today, 2.5.3.