LoginSignup
0
1

More than 3 years have passed since last update.

mac 「lib/libreadline.7.dylib (LoadError)」 の解決

Last updated at Posted at 2019-05-13

rails c ってやると、 libreadline のロードエラーが発生する。

Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
  Referenced from: /Users/fukmaru/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/readline.bundle
  Reason: image not found - /Users/fukmaru/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/readline.bundle

環境

$ rails -v
Rails 5.2.3
$ brew -v 
Homebrew 2.1.2
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]

解決方法

調べてみると、 libreadline のバージョンが8になったことで、旧バージョン(7)のファイルがなくなったために参照できなくなってしまったようだ。

Rubyを再インストール
$ rbenv uninstall 2.5.1
$ rbenv install 2.5.1

解決できた。ちなみに、bundlerを再インストールする必要があります。

$ gem install bundler
$ bundle install
Traceback (most recent call last):
    2: from /Users/fukmaru/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
    1: from /Users/fukmaru/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/fukmaru/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

ってエラーが出たら、

./Gemfile.lock
BUNDLED WITH
   1.17.2

で指定してるbundlerのバージョンと異なることが原因なので、versionを指定してください。

$ gem install bundler -v 1.17.2
$ bundle install

解決:sunny:

または、

その場しのぎの解決

シンボリックリンクを作成することで対応。

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

とりあえず、動くようにはなる。

0
1
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
0
1