完全卸载protobuf

mrg*_*oom 3 macos homebrew protocol-buffers

看来brew无法完全卸载protobuf:

\n\n
brew uninstall protobuf --force\nbrew uninstall protobuf@3.1 --force\n\nbrew info protobuf\nprotobuf: stable 3.6.1 (bottled), HEAD\nProtocol buffers (Google's data interchange format)\nhttps://github.com/protocolbuffers/protobuf/\nNot installed\nFrom: https://github.com/Homebrew/homebrew-core/blob/master/Formula/protobuf.rb\n==> Dependencies\nBuild: autoconf \xe2\x9c\x98, automake \xe2\x9c\x98, libtool \xe2\x9c\x94\nRecommended: python@2 \xe2\x9c\x94\nOptional: python \xe2\x9c\x98\n==> Options\n--with-python\n    Build with python support\n--without-python@2\n    Build without python2 support\n--HEAD\n    Install HEAD version\n==> Caveats\nEditor support and examples have been installed to:\n  /usr/local/Cellar/protobuf/3.6.1/share/doc/protobuf\n==> Analytics\ninstall: 20,550 (30 days), 75,916 (90 days), 307,704 (365 days)\ninstall_on_request: 10,362 (30 days), 36,197 (90 days), 141,839 (365 days)\nbuild_error: 0 (30 days)\n\nbrew uninstall protobuf\nError: No such keg: /usr/local/Cellar/protobuf\n\nprotoc\n-bash: /usr/local/opt/protobuf@3.1/bin/protoc: No such file or directory\n
Run Code Online (Sandbox Code Playgroud)\n\n

彻底卸载的正确方法是什么?

\n

bfo*_*ine 5

It\xe2\x80\x99s 不是 Homebrew\xe2\x80\x99s 错误:it\xe2\x80\x99s Bash\xe2\x80\x99。

\n\n

当您键入时protoc,Bash 会在您的PATH. 在你的情况下,它\xe2\x80\x99s /usr/local/opt/protobuf@3.1/bin/protoc。但是,它只在第一次执行此操作:它缓存会话的结果。

\n\n

您卸载了 protobuf,因此 Homebrew 删除了该/usr/local/opt/protobuf@3.1/bin/protoc文件;但你还没有清除 Bash\xe2\x80\x99 缓存,所以它仍然认为这个文件存在。

\n\n

解决方案是启动一个新的 shell 会话或强制 Bash 使用 清除其缓存hash -r

\n\n
\n\n

插图:

\n\n
$ touch /tmp/hi\n$ chmod u+x /tmp/hi\n$ export PATH="/tmp:$PATH"\n\n$ which hi\n/tmp/hi\n$ hi  # <-- executes /tmp/hi and cache hi=/tmp/hi\n\n$ rm /tmp/hi\n$ hi  # <-- still executes /tmp/hi because of the cache\nbash: /tmp/hi: No such file or directory\n\n$ hash -r # clear the cache\n$ hi\nhi: command not found\n
Run Code Online (Sandbox Code Playgroud)\n