当先锋百科网

首页 1 2 3 4 5 6 7

在使用brew 安装go时出现【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

解决方法:

1、输入命令 ' brew doctor '

$ 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

根据提示处理即可

  • 执行1
$ git -C "/opt/homebrew" remote set-url origin https://github.com/Homebrew/brew
  • 执行2
$ rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-cask"
$ brew tap homebrew/cask
  • 执行3
$ rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
$ brew tap homebrew/core

3、检查解决成功并安装go

 brew install go
brew doctor
Your system is ready to brew.
wjy@TianCai:~$ brew install go
Running `brew update --auto-update`...
==> Fetching dependencies for go: [email protected], glibc, gmp, isl, mpfr, libmpc, lz4, xz, zlib, zstd, binutils and gcc
==> Fetching [email protected]
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles//linux-
Already downloaded: /home/wjy/.cache/Homebrew/downloads/2113d57958844487619251ae54a95ac56cbf541ea015be3e0390632d[email protected]_64_linux.bottle.tar.gz
==> Fetching glibc
....


==> Running `brew cleanup go`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
wjy@TianCai:~$ go version
go version go1.20.1 linux/amd64

安装成功