代码之家  ›  专栏  ›  技术社区  ›  mrgloom

完全卸载protobuf

  •  2
  • mrgloom  · 技术社区  · 6 年前

    似乎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
    

    完全卸载它的正确方法是什么?

    1 回复  |  直到 6 年前
        1
  •  3
  •   bfontaine cat-walk    6 年前

    它不是自制的错误:它是bash。

    当你打字的时候 protoc ,bash在 PATH . 在您的案例中,它是 /usr/local/opt/protobuf@3.1/bin/protoc . 然而,它只在第一次这样做:它为会话缓存其发现。

    您卸载了Protobuf,因此自制删除了 /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