Homebrew 因升级出现 "Library not loaded"的处理 - konakona
konakona
Dream Afar.
konakona

Homebrew 因升级出现 "Library not loaded"的处理

Homebrew 因升级出现

很久没有写php了,像往常一样先升个级。

brew install php@8.2

安装后打算修改~/.zshrc让命令行使用8.2版本,发现无法运行vim,提示如下报错信息:

➜ ~ vim
dyld[28879]: Library not loaded: /opt/homebrew/opt/libsodium/lib/libsodium.23.dylib
  Referenced from: <BA441469-20D2-3A07-ABCE-790A3BE0C6E1> /opt/homebrew/Cellar/vim/9.0.1650/bin/vim
  Reason: tried: '/opt/homebrew/opt/libsodium/lib/libsodium.23.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libsodium/lib/libsodium.23.dylib' (no such file), '/opt/homebrew/opt/libsodium/lib/libsodium.23.dylib' (no such file), '/usr/local/lib/libsodium.23.dylib' (no such file), '/usr/lib/libsodium.23.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/libsodium/1.0.19/lib/libsodium.23.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/libsodium/1.0.19/lib/libsodium.23.dylib' (no such file), '/opt/homebrew/Cellar/libsodium/1.0.19/lib/libsodium.23.dylib' (no such file), '/usr/local/lib/libsodium.23.dylib' (no such file), '/usr/lib/libsodium.23.dylib' (no such file, not in dyld cache)
[1]    28879 abort      vim

这是因为 homebrew 的软链有问题,重新进行软链搞定:

ln -s  /opt/homebrew/Cellar/libsodium/1.0.19/lib/libsodium.26.dylib /opt/homebrew/opt/libsodium/lib/libsodium.23.dylib

接着运行vim会遇到新的报错:

➜ lib (stable) ✔ vim
dyld[35527]: Library not loaded: /opt/homebrew/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/CORE/libperl.dylib
  Referenced from: <BA441469-20D2-3A07-ABCE-790A3BE0C6E1> /opt/homebrew/Cellar/vim/9.0.1650/bin/vim
  Reason: tried: '/opt/homebrew/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/CORE/libperl.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/CORE/libperl.dylib' (no such file), '/opt/homebrew/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/CORE/libperl.dylib' (no such file), '/usr/local/lib/libperl.dylib' (no such file), '/usr/lib/libperl.dylib' (no such file, not in dyld cache)
[1]    35527 abort      vim

显然是vim使用了错误的perl版本导致的问题,这是因为在brew upgrade的过程中,perl进行了升级,而vim仍在使用指定的perl版本,这里vim官方issue中有讨论到。通过查阅issue的讨论内容,找到一个最有效的做法就是重装vim,问题解决。

brew reinstall vim 

Every time perlpython or ruby are upgraded or revision bumped, vim needs to be brew reinstall‘d. It’s a known issue. This would be a known issue even against the system Perl if Apple ever gets round to implementing another major Perl update.

看来锅是苹果的呀……
赞赏
没有标签
首页      程序开发      PHP      Homebrew 因升级出现 "Library not loaded"的处理

团哥

文章作者

继续玩我的CODE,让别人说去。 低调,就是这么自信。

konakona

Homebrew 因升级出现 "Library not loaded"的处理
macos下perl升级并不会联动更新vim的perl指向导致的问题。
扫描二维码继续阅读
2023-12-21