Cannot execute “rails console” due to an error with readline

血红的双手。 提交于 2019-11-28 16:36:37
wmmc

I had the same issue recently with homebrew and libreadline.7.x.dylib / libreadline.6.x.dylib

I solved it by running:

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

source: https://github.com/rails/rails/issues/26658

Giuseppe

Homebrew is great, but once in a while it doesn't play nice with some of the other moving parts.

A brew update && brew upgrade brought in libreadline.7.x.dylib while automatically removing libreadline.6.x.dylib, which ruby was still relying on.

There may be more clever ways to fix the problem, but brute force worked for me:

$ rbenv uninstall 2.3.1
$ rbenv install 2.3.1
$ cd /path/to/my/app
$ bundle

The above assumes the presence of rbenv's ruby-build and, of course, bundler; replace 2.3.1 with whatever version of ruby you are using.

Please note that similar problems can occur with different homebrew-managed libraries (see my own answer to this, for example)

I'm on OSX, ruby2.3.0, rails5. Adding gem 'rb-readline' to my Gemfile fixed this problem.

I got the same error with Ruby 2.1.0, and rails 4.0. After searching and trying a lot, finally it work well:) Here are what I did:

rvm cleanup all
rvm autolibs enable
rvm install 2.1.0 

The other ways:

brew update
brew uninstall readline
brew install readline

The autolibs command will force RVM install all dependencies, so you don't need to worry about it.

Hope it's helpful.

As Sachin hinted, installing readline and then reinstalling ruby is the ideal approach - but the details are a bit different for rbenv. Given your file paths, I'm guessing you're on a Mac, so the following should help:

brew install readline ruby-build
env CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 1.9.3-p286

This was taken from the ruby-build Wiki and a quick google search.

violentr

Using mac, El Captain version, it is possible to fix just by doing

rvm reinstall your_ruby_version

(like rvm reinstall ruby-2.3.1)

Hope this helps, good luck!

taken from github user @enderahmetyurt (this is the only solution that worked for me).

Solution: Add gem 'rb-readline' to your Gemfile in development group and bundle install.

It's the easiest solution for silly "readline" errors.

try installing readline, and reinstall your ruby

https://rvm.io/packages/readline/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!