What is the best/safest way to reinstall Homebrew?

前端 未结 6 1622
一向
一向 2020-12-02 06:21

I am getting issues with permissions in Homebrew: After I installed Node and tried to install npm using the curl command Homebrew tells you to use, it would fail due to EACC

相关标签:
6条回答
  • 2020-12-02 06:28

    For Mac OS X Mojave and above

    To Uninstall Homebrew, run following command:

    sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
    

    To Install Homebrew, run following command:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    And if you run into Permission denied issue, try running this command followed by install command again:

    sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/*
    
    0 讨论(0)
  • 2020-12-02 06:34

    Try running the command brew doctor and let us know what sort of output you get


    edit: And to answer the title question, this is from their FAQ :

    Homebrew doesn’t write files outside its prefix. So generally you can just rm -rf the folder you installed it in.

    So following that up with a clean re-install (following their latest recommended steps) should be your best bet.

    0 讨论(0)
  • 2020-12-02 06:34

    Update 10/11/2020 to reflect the latest brew changes.

    Brew already provide a command to uninstall itself:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
    

    If you failed to run this command due to permission (like run as second user), run again with sudo

    Then you can install again:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    
    0 讨论(0)
  • 2020-12-02 06:37

    Process is to clean up and then reinstall with the following commands:

    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
    

    Notes:

    • Always check curl | bash (or ruby) commands before running them
    • http://brew.sh/ (for installation notes)
    • https://raw.githubusercontent.com/Homebrew/install/master/install (for clean up notes, see "Homebrew is already installed")
    0 讨论(0)
  • 2020-12-02 06:41

    The way to reinstall Homebrew is completely remove it and start over. The Homebrew FAQ has a link to a shell script to uninstall homebrew.

    If the only thing you've installed in /usr/local is homebrew itself, you can just rm -rf /usr/local/* /usr/local/.git to clear it out. But /usr/local/ is the standard Unix directory for all extra binaries, not just Homebrew, so you may have other things installed there. In that case uninstall_homebrew.sh is a better bet. It is careful to only remove homebrew's files and leave the rest alone.

    0 讨论(0)
  • 2020-12-02 06:48

    For me, this one worked without the sudo access.

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    For more reference, please follow https://gist.github.com/mxcl/323731

    0 讨论(0)
提交回复
热议问题