似乎brew无法完全卸载protobuf:
brew uninstall protobuf --force
brew uninstall protobuf@3.1 --force
brew info protobuf
protobuf: stable 3.6.1 (bottled), HEAD
Protocol buffers (Google's data interchange format)
https://github.com/protocolbuffers/protobuf/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/protobuf.rb
==> Dependencies
Build: autoconf ✘, automake ✘, libtool ✔
Recommended: python@2 ✔
Optional: python ✘
==> Options
--with-python
Build with python support
--without-python@2
Build without python2 support
--HEAD
Install HEAD version
==> Caveats
Editor support and examples have been installed to:
/usr/local/Cellar/protobuf/3.6.1/share/doc/protobuf
==> Analytics
install: 20,550 (30 days), 75,916 (90 days), 307,704 (365 days)
install_on_request: 10,362 (30 days), 36,197 (90 days), 141,839 (365 days)
build_error: 0 (30 days)
brew uninstall protobuf
Error: No such keg: /usr/local/Cellar/protobuf
protoc
-bash: /usr/local/opt/protobuf@3.1/bin/protoc: No such file or directory
完全卸载它的正确方法是什么?
答案 0 :(得分:3)
这不是Homebrew的错:是Bash。
当您键入protoc
时,Bash将在您的PATH
中搜索可执行文件。您的情况是/usr/local/opt/protobuf@3.1/bin/protoc
。但是,它只是第一次这样做:它会为会话缓存其发现。
您卸载了protobuf,因此Homebrew删除了/usr/local/opt/protobuf@3.1/bin/protoc
文件;但您尚未清除Bash的缓存,因此它仍然认为该文件存在。
解决方案是启动一个新的Shell会话,或强制Bash使用hash -r
清除其缓存。
插图:
$ touch /tmp/hi
$ chmod u+x /tmp/hi
$ export PATH="/tmp:$PATH"
$ which hi
/tmp/hi
$ hi # <-- executes /tmp/hi and cache hi=/tmp/hi
$ rm /tmp/hi
$ hi # <-- still executes /tmp/hi because of the cache
bash: /tmp/hi: No such file or directory
$ hash -r # clear the cache
$ hi
hi: command not found