rails: rails c doesn't start the rails console.

I am not able to load the rails console.

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
~/opensource/intranet(master)*$ rails -v
Rails 4.2.0
$ rails s
=> Booting Thin
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop
^CStopping ...
Exiting
$ rails c
/Users/prasad/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/irb/completion.rb:9:in `require': dlopen(/Users/prasad/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/prasad/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/prasad/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/readline.bundle
    from /Users/prasad/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/irb/completion.rb:9:in `<top (required)>'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands/console.rb:3:in `require'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands/console.rb:3:in `<top (required)>'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:123:in `require'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:123:in `require_command!'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:58:in `console'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/prasad/.rvm/gems/ruby-2.2.4/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Expected behaviour

Rails console should be loaded for rails c

Actual behaviour

Rails console doesnt load on rails c.

System configuration

Rails version: 4.2.0 Ruby version: 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 44 (4 by maintainers)

Commits related to this issue

Most upvoted comments

works for me: ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

16/01/2019 @saxxi upd: ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

Add ‘rb-readline’ gem to your Gemfile in development group and install it. It’s the easiest solution for silly “readline” errors. Other solutions didn’t work for me. 😦

Fyi @LegaKh’s solution still applies, I had to do:

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

My case, sidekiq wouldn’t start.

  • ruby installed via rbenv (rbenv-build)
  • readline installed via brew (Homebrew)

I unwisely did a brew update which changed my readline installation to one that my ruby install was not compiled with.

My steps to correction: Note: for good measure, I rehashed rbenv rbenv rehash and started a new terminal session after just about every step.

  1. Uninstall offending version of ruby (2.2.0): rbenv uninstall 2.2.0
  2. Made sure homebrew had installed readline: brew install readline
  3. Reinstall ruby (2.2.0) with brew readline linkage: RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.2.0 _More on this: https://github.com/rbenv/ruby-build/wiki_
  4. Install bundler: gem install bundler
  5. Install gem bundle (assumes Gemfile): bundle

Just reinstall your current ruby version, worked for me on ruby 2.1.2

This is not an issue related to Rails. See how to solve issues with rvm and readline. You will face this issue with any other gem which tries to use readline as well as the issue with your Ruby installation.

Thanks!

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

If you’re using rvm you can run this to reinstall the current version which worked for me 😃

rvm reinstall $(rvm current)

Also some great options to try out here: https://stackoverflow.com/questions/16756287/cannot-execute-rails-console-due-to-an-error-with-readline/16775469

gem ‘rb-readline’ as enderahmetyurt said works fine for rails console.

Same issue,

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

works perfectly

works for me: ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

16/01/2019 @saxxi upd: ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

@saxxi Thank you. That worked for me as well!

Thanks @enderahmetyurt. It definitely was the easiest solution! Mac OSX 10.12.3, Ruby-2.3.0 and Rails-5.0.1

I had to use @enderahmetyurt’s solution first and then create the symlink using @LegaKh’s suggestion.

The same problem here. What helped in the end was:

brew upgrade readline
rvm reinstall VERSION

@cmolenda reinstalling Ruby is what did it for me. Homebrew must have decided to upgrade readline without me knowing, which broke Ruby. Yay development tooling!

@enderahmetyurt give this man a beer

Thanks @enderahmetyurt. It works!

@jeffrey008 I imploded the RVM and reinstalled it.

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

Run above code and then run rails c

Then it should work.

My case, sidekiq wouldn’t start.

* `ruby` installed via `rbenv` (`rbenv-build`)

* `readline` installed via `brew` (Homebrew)

I unwisely did a brew update which changed my readline installation to one that my ruby install was not compiled with.

My steps to correction: Note: for good measure, I rehashed rbenv rbenv rehash and started a new terminal session after just about every step.

1. Uninstall offending version of ruby (2.2.0): `rbenv uninstall 2.2.0`

2. Made sure homebrew had installed readline: `brew install readline`

3. Reinstall ruby (2.2.0) with brew readline linkage: `RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.2.0`
   _More on this: https://github.com/rbenv/ruby-build/wiki_

4. Install bundler: `gem install bundler`

5. Install gem bundle (assumes Gemfile): `bundle`

This solution worked for me working with a Docker image of ruby:2.6. I wonder why I had to do that on my host machine so that my entrypoint configured as irb could work. Thanks @cmolenda.