19
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macでawkを実行するとエラー: "dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib" となる問題の解決法

Posted at

解決したいこと

awkを実行すると以下のエラーが発生しました。
(エラーが発生するようになった原因は不明で、調査中です)

$ awk
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/bin/awk
  Reason: image not found
Abort trap: 6

解決法

解決法は**readlineをインストールし直す**です。

/usr/local/opt/readline/lib/libreadline.7.dylibがnot foundといっていて、実際に存在を確認してもなかったので、入れ直せばいいと思い入れ直したら、うまくいきました。以下は解決の手順です。

以下のようにbrew info readlineで利用可能なバージョンを調べます。libreadline.7.dylib7が含まれていたので、バージョンは7系が良さそうかなと思い、7系の最新の7.0.5が良さそうです。

$brew info readline
https://tiswww.case.edu/php/chet/readline/rltop.html
/usr/local/Cellar/readline/6.3.8 (46 files, 2.0MB)
  Poured from bottle on 2015-09-11 at 23:22:41
/usr/local/Cellar/readline/7.0 (45 files, 2MB)
  Poured from bottle on 2016-10-01 at 06:49:56
/usr/local/Cellar/readline/7.0.1 (46 files, 2MB)
  Poured from bottle on 2017-01-24 at 13:25:38
/usr/local/Cellar/readline/7.0.3_1 (46 files, 1.5MB)
  Poured from bottle on 2017-03-23 at 13:40:32
/usr/local/Cellar/readline/7.0.5 (46 files, 1.5MB)
  Poured from bottle on 2018-10-02 at 11:09:53
/usr/local/Cellar/readline/8.0.0 (48 files, 1.5MB)
  Poured from bottle on 2019-01-23 at 17:00:02

あとは、以下のコマンドを打って、無事に解決しました。

$ brew switch readline 7.0.5

以下のように無事にヘルプが出るようになりました。

 awk
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:		GNU long options: (standard)
	-f progfile		--file=progfile
	-F fs			--field-separator=fs
	-v var=val		--assign=var=val
Short options:		GNU long options: (extensions)
	-b			--characters-as-bytes
	-c			--traditional
	-C			--copyright
	-d[file]		--dump-variables[=file]
	-D[file]		--debug[=file]
	-e 'program-text'	--source='program-text'
	-E file			--exec=file
...

参考

19
5
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
19
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?