LoginSignup
42
33

More than 5 years have passed since last update.

rails consoleでreadline(LoadError)が出た場合の対処

Posted at

railsプロジェクトを作って、 rails console をしたら以下のようなエラーが出た。

$ bundle exec rails console
~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/irb/completion.rb:9:in `require': dlopen(~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/x86_64-darwin13.0/readline.bundle, 9): Library not loaded: @@HOMEBREW_PREFIX@@/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: ~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/x86_64-darwin13.0/readline.bundle
  Reason: image not found - ~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/x86_64-darwin13.0/readline.bundle
        from ~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'

単純にインストールし忘れたと思ったけど、違った。

$ brew install readline
Warning: readline-6.3.8 already installed

どうやら、rb-readlineが必要らしいので、Gemfileにgem 'rb-readline' を追加してインストール

$ bundle install --path vendor/bundle

もう一度実行。

$ bundle exec rails console
Loading development environment (Rails 4.1.6)
irb(main):001:0>

成功!

42
33
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
42
33