小林ノエルのエンジニア的忘備録

フリーランス兼会社員エンジニアが技術とかリモートワークのこととかをツラツラ書いていきます

byebugが【Sorry, you can't use byebug without Readline】と出て起動しなくなった時の対処メモ

問題

ある日rails cをやったらこんなエラーが出た。

$ rails c
    Sorry, you can't use byebug without Readline. To solve this, you need to
    rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
    install libreadline-dev` and then reinstall your Ruby.
/Users/noel/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/noel/.rbenv/versions/2.6.2/lib/ruby/2.6.0/x86_64-darwin18/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /Users/noel/.rbenv/versions/2.6.2/lib/ruby/2.6.0/x86_64-darwin18/readline.bundle
  Reason: image not found - /Users/noel/.rbenv/versions/2.6.2/lib/ruby/2.6.0/x86_64-darwin18/readline.bundle (LoadError)

ググったら原因はreadlineがアップデートされたことによるものだろうという記事が何個か出てきた。

そういえばこのまえasdfのインストールするときにreadlineをhomebrewでいれたことを思い出した。

f-world21.hatenablog.com

解決方法

解決方法は何個かあるようだったが、rubyの再インストールが1番良さそうだったのでそのようにした。

$ rbenv uninstall 2.6.2
rbenv: remove /Users/noel/.rbenv/versions/2.6.2? [yN] y
$ rbenv install 2.6.2

これでひとまず解決!

環境

  • macOS Mojave 10.14.6
  • ruby 2.6.2
  • readline 8.0.0(homebrewでインストール)