MacOSX
homebrew

Homebrewで古いバージョンのdylibにswitchする

More than 1 year has passed since last update.

mpvを使おうとすると

dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
  Referenced from: /usr/local/bin/mpv
  Reason: image not found
Trace/BPT trap: 5

/usr/local/opt/jpeg/libを見ると

バージョンが上がっている

drwxr-xr-x 5 yukpiz admin    170 10 24 11:19 .
drwxr-xr-x 9 yukpiz admin    306 10 23 11:17 ..
-r--r--r-- 1 yukpiz admin 207280 10 23 11:17 libjpeg.9.dylib
-r--r--r-- 1 yukpiz admin 276744  1 17  2016 libjpeg.a
lrwxr-xr-x 1 yukpiz admin     15  1 17  2016 libjpeg.dylib -> libjpeg.9.dylib

古いバージョンが手元に残っているか調べる

8dが残っている

$ brew info libjpeg
jpeg: stable 9b (bottled)
Image manipulation library
http://www.ijg.org
/usr/local/Cellar/jpeg/8d (19 files, 713.8KB)
  Poured from bottle on 2016-12-16 at 19:52:28
/usr/local/Cellar/jpeg/9b (20 files, 725.2KB) *
  Poured from bottle on 2017-10-23 at 11:17:58
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/jpeg.rb

8dに切り替える

$ brew switch libjpeg 8d
Cleaning /usr/local/Cellar/jpeg/8d
Cleaning /usr/local/Cellar/jpeg/9b
17 links created for /usr/local/Cellar/jpeg/8d

9bにも戻せます

$ brew switch libjpeg 9b
Cleaning /usr/local/Cellar/jpeg/8d
Cleaning /usr/local/Cellar/jpeg/9b
17 links created for /usr/local/Cellar/jpeg/9b

参考

https://qiita.com/honeniq/items/778cc08d2db78e6774d8