Cannot Execute "Rails Console" Due to an Error with Readline

rails console doesn't load due to libreadline

Ran across this today, to solve it I did:

brew rm -f readline

brew install readline

brew link readline --force

Hope it helps.

EDIT: I recently ran into this problem again (after downgrading Ruby) since I wrote this, and I now prefer @califrench's solution from the comments below:

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

Why do I get a Readline error when trying to start rails console?

Please read the output of:

rvm requirements

It will show you list of libraries you need to install to make good use of Ruby

After installing all the libs, clean rvm installed libs and reinstall Ruby:

rm -rf $rvm_path/usr
rvm reinstall 1.9.3

Unable to Execute Rails console command Ruby

Might not be related, but I had the same thing happen to me today.

I had a fully-functioning Ruby 2.3.1 working fine this morning. In my case, Ruby was compiled and installed by ruby-build and managed by rbenv.

At one point today I updated Homebrew with

brew cleanup --prune=30
brew update
brew upgrade

One of the formulae upgraded was readline 7.0:

$ brew info readline
...
/usr/local/Cellar/readline/7.0 (45 files, 2M)
Poured from bottle on 2016-10-05 at 08:09:22

Shortly afterwords I found that my readline support for Ruby had become completely broken. I saw errors just like yours:

/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `require': dlopen(/Users/mbrictson/.rbenv/versions/2.3.1/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/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `lazy_readline'

The solution was to completely delete my Ruby installation and recompile it:

rm -rf ~/.rbenv/versions/2.3.1
rbenv install 2.3.1

I know you are using rvm and not rbenv, but perhaps the solution in your case is similar: delete your Ruby installation and re-install it using rvm.

rails console require cannot load such file readline

Readline gem is required by your application but not specified in your Gemfile

Please add this to your gem file

gem 'rb-readline' 

Also reinstall

libreadline-dev

Rails Console Not Loading

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

Try the following:

brew link readline --force

Why does Rails console say cannot load such file -- readline?

You need to have the readline libraries installed when you compile Ruby.

If you are on CentOS/Redhat/Fedora Linux, install the package using:

sudo yum install readline-devel

Or, on Ubuntu, use:

sudo apt-get install libreadline6 libreadline6-dev

and then recompile Ruby.

Problems with the rails console, RVM and readline

I had a similar problem it was with 1.9.2 on Ubuntu 10.04, but the symptoms were identical. In order to get it to work:

rvm pkg install readline

or prior to RVM version 1.6.32, you need the following command

rvm package install readline

Then:

apt-get install ncurses-dev

And then taking from their instructions at http://rvm.beginrescueend.com/packages/readline/

cd $HOME/.rvm/src/ruby-1.9.2-p0/ext/readline
ruby extconf.rb -- --with-readline-dir="$HOME/.rvm/usr"
make install

I had actually done a system rvm install on the server, so I needed to do this:

cd $HOME/.rvm/src/ruby-1.9.2-p0/ext/readline
ruby extconf.rb -- --with-readline-dir="/usr/local/rvm/usr"
make install

After that I was able to have full access to the console.



Related Topics



Leave a reply



Submit