關於homebrew使用時遇到的問題: Error: Could not symlink bin/gdb/usr/local/bin is not writable.


關於homebrew使用時遇到的問題: Error: Could not symlink bin/gdb/usr/local/bin is not writable.


這是我在給我的Mac電腦安裝GDB的時候遇到的問題:

我的Mac使用homebrew管理,於是我使用brew install gdb命令直接安裝gdb,結果如下:

我在stackoverflow找到了發生的類似情況,經過閱讀判斷,找到了一下兩種解決辦法:

  • 如圖,直接輸入命令:

命令內容:

sudo chown -R `whoami`:admin /usr/local/bin
  • 如圖,為了謹慎起見,使用homebrew doctor進行檢測,根據其反饋來進行操作:

我認為應該使用第二中方法比較好,於是我在終端輸入homebrew doctor,稍作等待得到檢測結果:

如划紅線部分所示,與我遇到的問題相符合,運行其解決方案:
sudo chown -R $(whoami) /usr/local/bin
在此時再link一下我的GDB:
brew link gdb
結果如下:
Already linked: /usr/local/Cellar/gdb/8.0.1
再測試一下GDB:
gdb
結果如下:

成功.

那么問題的原因是什么呢?

  • 問題出現在我之前安裝OpenSSL時使用了sudo make install命令,導致了一些軟件非homebrew管理,所以homebrew在Link的時候會出現問題。
  • 參考homebrew doctor如下提示:
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.
You should change the ownership and permissions of these directories.
back to your user account.

參考資料

用brew安裝node遇到的問題
Error: The 'brew link' step did not complete successfully
homebrew could not symlink usr/local/bin is not writable


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM