使用brew安装golang时出现,Error: Command failed with exit 128: git
$ brew install go
==> Fetching go
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/go-1.19.4.arm64_ventura.bottle.tar.gz
######################################################################## 100.0%
fatal: not in a git directory
Error: Command failed with exit 128: git
解决办法
$ brew doctor
brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Suspicious https://github.com/Homebrew/brew git origin remote found.
The current git origin is:
https://mirrors.aliyun.com/homebrew/brew.git
With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
git -C "/opt/homebrew" remote set-url origin https://github.com/Homebrew/brew
Warning: Homebrew/homebrew-cask was not tapped properly! Run:
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-cask"
brew tap homebrew/cask
Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core
根据提示处理即可
$ git -C "/opt/homebrew" remote set-url origin https://github.com/Homebrew/brew
$ rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-cask"
$ brew tap homebrew/cask
$ rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
$ brew tap homebrew/core
完美解决
$ brew install go
==> Fetching go
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/go-1.19.4.arm64_ventu
Already downloaded: /Users/4wheels/Library/Caches/Homebrew/downloads/56740eebcb6f4b0859fe3baa5914a4bd2a7a2216f6b10a525dd5e5f24f69ad36--go-1.19.4.arm64_ventura.bottle.tar.gz
==> Pouring go-1.19.4.arm64_ventura.bottle.tar.gz
/opt/homebrew/Cellar/go/1.19.4: 12,452 files, 629.1MB
==> Running `brew cleanup go`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
$ go version
go version go1.19.4 darwin/arm64