- 前情
- install/reinstall均失敗,提示鏈接文件不存在
- 檢查鏈接文件是存在的
- debug查看詳情,關鍵的報錯信息還是這條文件或目錄不存在
- 確認鏈接的目標文件是否存在,結果確實不存在
- 刪除鏈接文件,重新brew install,OK
前情
在之前的MBP上是安裝過nmap的,也是正常使用的。最近換了新的MBP,系統升級到了macOS Monterey 12.1
,之前的數據是用蘋果的時間機器遷移過來的;因為機器的CPU從x86架構變成了arm架構,有部分軟件不能正常工作,已經陸續做了修復。
今天發現nmap也不能正常使用了,一番小鼓搗修復了,問題的處理很簡單,但是在網絡上搜索相關錯誤關鍵字貌似沒有相關的Case,因此還是簡單記錄一下,方便后面的同學。
此類問題應該是會出現在「之前通過homebrew安裝過某些軟件」,但是「軟件的鏈接文件失效」的場景。解決方法也是具有一定的通用性的。
以上。
install/reinstall均失敗,提示鏈接文件不存在
➜ /Users/stephen >brew install nmap
Running `brew update --preinstall`...
Error: No such file or directory - /usr/local/var/homebrew/linked/nmap
➜ /Users/stephen >
檢查鏈接文件是存在的
➜ /Users/stephen >ls /usr/local/var/homebrew/linked/nmap
/usr/local/var/homebrew/linked/nmap
➜ /Users/stephen >ll /usr/local/var/homebrew/linked/nmap
lrwxr-xr-x 1 stephen admin 25 Nov 4 2016 /usr/local/var/homebrew/linked/nmap -> ../../../Cellar/nmap/7.31
➜ /Users/stephen >
debug查看詳情,關鍵的報錯信息還是這條文件或目錄不存在
➜ /Users/stephen >brew install nmap -debug
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nmap.rb
Error: Calling brew install --env is disabled! Use `env :std` in specific formula files instead.
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:143:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in `<main>'
➜ /Users/stephen >brew install nmap --debug
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nmap.rb
Error: No such file or directory - /usr/local/var/homebrew/linked/nmap
/usr/local/Homebrew/Library/Homebrew/keg.rb:142:in `for'
/usr/local/Homebrew/Library/Homebrew/formula.rb:638:in `linked_version'
/usr/local/Homebrew/Library/Homebrew/install.rb:216:in `install_formula?'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:200:in `block in install'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:199:in `select'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:199:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in `<main>'
➜ /Users/stephen >
確認鏈接的目標文件是否存在,結果確實不存在
➜ /Users/stephen >ll /usr/local/var/homebrew/linked/nmap
lrwxr-xr-x 1 stephen admin 25 Nov 4 2016 /usr/local/var/homebrew/linked/nmap -> ../../../Cellar/nmap/7.31
➜ /Users/stephen >
➜ /Users/stephen >cd /usr/local/var/homebrew/linked/
➜ /usr/local/var/homebrew/linked >ls ../../../Cellar/nmap/7.31
ls: ../../../Cellar/nmap/7.31: No such file or directory
➜ /usr/local/var/homebrew/linked >cd ../../../Cellar/
➜ /usr/local/Cellar >ls | grep nmap
➜ /usr/local/Cellar >ls | grep -i nmap
刪除鏈接文件,重新brew install,OK
➜ /usr/local/Cellar >rm -f /usr/local/var/homebrew/linked/nmap
➜ /usr/local/Cellar >
➜ /usr/local/Cellar >brew install nmap
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/nmap-7.92.monterey.bottle.tar.gz
######################################################################## 100.0%
==> Pouring nmap-7.92.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/nmap/7.92: 829 files, 26.7MB
==> Running `brew cleanup nmap`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
➜ /usr/local/Cellar >
➜ /usr/local/Cellar >nmap --version
Nmap version 7.92 ( https://nmap.org )
Platform: x86_64-apple-darwin21.1.0
Compiled with: nmap-liblua-5.3.5 openssl-1.1.1l nmap-libssh2-1.9.0 libz-1.2.11 nmap-libpcre-7.6 libpcap-1.9.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: kqueue poll select
➜ /usr/local/Cellar >