mac环境下brew command not found错误的解决方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac环境下brew command not found错误的解决方法相关的知识,希望对你有一定的参考价值。

参考技术A mac环境下brew command not found错误的解决方法

操作如下

打开终端 - 输入以下命令:

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

1

由于国内某些原因,导致http://raw.githubusercontent.com/被墙了,无法访问,提示以下错误:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

1

第一种解决方法:

设置mac的DNS为114.114.114.114或者8.8.8.8

设置DNS方法:设置DNS的办法

第二种解决方法:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

————————————————

mac 使用brew安装提示fatal: not in a git directory Error: Command failed with exit 128: git

在使用brew 安装scrcpy的时候出现以下问题:

==> Installing dependencies for scrcpy: dav1d, frei0r, bdw-gc, libffi, pkg-config, guile, libtasn1, nettle, p11-kit, libevent, unbound, gnutls, lame, fribidi, pcre, python@3.9, glib, libpthread-stubs, xorgproto, libxau, libxdmcp, libxcb, libx11, libxext, libxrender, lzo, pixman, cairo, gobject-introspection, graphite2, harfbuzz, libass, libbluray, cjson, cmocka, mbedtls, librist, libsoxr, libvidstab, libogg, libvorbis, libvpx, opencore-amr, little-cms2, openjpeg, opus, rav1e, flac, libsndfile, libsamplerate, rubberband, sdl2, snappy, speex, srt, leptonica, libb2, lz4, libarchive, tesseract, theora, x264, x265, xvid, zeromq, zimg, ffmpeg and libusb
==> Installing scrcpy dependency: dav1d
fatal: not in a git directory
Error: Command failed with exit 128: git

经过一番折腾,记录以下解决方式:
通过brew -v命令来查看下是否有以下提示:

Homebrew 3.4.10-54-g987e688
fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else)
To add an exception for this directory, call:

	git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else)
To add an exception for this directory, call:

	git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)

如果出现以上信息的话,只需要安装上面的提示执行以下命令:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

问题找到解决方式之后,就感觉其实很简单。

以上是关于mac环境下brew command not found错误的解决方法的主要内容,如果未能解决你的问题,请参考以下文章

Mac终端出现 brew command not found 解决

Mac 终端报错 zsh: command not found: brew 解决方案

解决mac安装homebrew后报错-bash: brew: command not found

mac 使用brew安装提示fatal: not in a git directory Error: Command failed with exit 128: git

mac 使用brew安装提示fatal: not in a git directory Error: Command failed with exit 128: git

mac环境下配置adb环境以及解决-bash: adb: command not found