ごんれのラボ

iOS、Android、Adobe系ソフトの自動化スクリプトのことを書き連ねています。

Homebrewでreadlineのバージョンを切り替える方法

方法

readlineのバージョンを brew info readline で調べる。

$ brew info readline
readline: stable 8.0.0 (bottled) [keg-only]
Library for command-line editing
https://tiswww.case.edu/php/chet/readline/rltop.html
/usr/local/Cellar/readline/7.0.3_1 (46 files, 1.5MB)
  Poured from bottle on 2018-06-26 at 09:48:16
/usr/local/Cellar/readline/7.0.5 (46 files, 1.5MB)
  Poured from bottle on 2018-07-30 at 18:56:16
/usr/local/Cellar/readline/8.0.0 (48 files, 1.5MB)
  Poured from bottle on 2019-02-01 at 11:40:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/readline.rb
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

==> Analytics
install: 493,453 (30 days), 992,713 (90 days), 3,374,936 (365 days)
install_on_request: 57,851 (30 days), 99,242 (90 days), 316,807 (365 days)
build_error: 0 (30 days)

使いたいバージョンに切り替える。

brew switch readline 7.0.5

なぜ

気軽に brew install hoge した結果、readlineがUpdateされて、Tigが使えなくなったので、readlineのバージョンを切り替えたかった。

$ tig
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/bin/tig
  Reason: image not found
zsh: abort      tig

他に影響がないかはそのとき考える…。

参考

https://blog.skylarking.me/2016/10/07/psql-readline-error/