➜ ~ brew update-reset ==> Fetching /usr/local/Homebrew... error: cannot open .git/FETCH_HEAD: Permission denied error: Unable to create '/usr/local/Homebrew/.git/refs/remotes/origin/HEAD.lock': Permission denied error: Could not setup refs/remotes/origin/HEAD
==> Resetting /usr/local/Homebrew... fatal: ref refs/remotes/origin/HEAD is not a symbolic ref fatal: 'origin/HEAD' is not a commit and a branch '' cannot be created from it
==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask... error: cannot open .git/FETCH_HEAD: Permission denied error: Unable to create '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/refs/remotes/origin/HEAD.lock': Permission denied error: Could not setup refs/remotes/origin/HEAD
==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask... fatal: Unable to create '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/index.lock': Permission denied
==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core... error: cannot open .git/FETCH_HEAD: Permission denied error: Unable to create '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/refs/remotes/origin/HEAD.lock': Permission denied error: Could not setup refs/remotes/origin/HEAD
==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core... fatal: Unable to create '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/index.lock': Permission denied
我一看这是权限不够,加权限吧。
➜ ~ sudo brew update-reset Password: Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.
➜ ~ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ==> Checking for `sudo` access (which may request your password)... ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew ==> The following existing directories will be made group writable: /usr/local/etc/bash_completion.d /usr/local/share/aclocal /usr/local/share/info /usr/local/share/locale /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/bin/brew ==> The following existing directories will have their owner set to sunyg: /usr/local/etc/bash_completion.d /usr/local/share/aclocal /usr/local/share/info /usr/local/share/locale /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/bin/brew ==> The Xcode Command Line Tools will be installed.
➜ ~ sudo chown -R sunyg /usr/local/var/homebrew ➜ ~ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ==> Checking for `sudo` access (which may request your password)... ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew
Press RETURN/ENTER to continue or any other key to abort: ==> /usr/bin/sudo /usr/sbin/chown -R sunyg:admin /usr/local/Homebrew ==> Downloading and installing Homebrew... HEAD is now at 044d06d10 Merge pull request #16524 from Homebrew/dependabot/bundler/Library/Homebrew/sorbet-runtime-and-sorbet-static-and-runtime-0.5.11216 ==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:02180ca8b8295422ae84921bcf034b7ee8ce5575488bd5e6a37a192e53cd5d34 ######################################################################### 100.0% ==> Pouring portable-ruby-3.1.4.el_capitan.bottle.tar.gz Installing from the API is now the default behaviour! You can save space and time by running: brew untap homebrew/core brew untap homebrew/cask ==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation(and how to opt-out) here: https://docs.brew.sh/Analytics No analytics data has been sent yet(nor will any be during this install run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations
==> Next steps: - Run these two commands in your terminal to add Homebrew to your PATH: (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/sunyg/.zprofile eval "$(/usr/local/bin/brew shellenv)" - Run brew help to get started - Further documentation: https://docs.brew.sh
警告
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.