mac 终端 报-bash: brew: command not found 解决办法以及通过 brew install scrcpy 安装步骤

之前有安装过HomeBrew,但最近执行 brew install scrcpy 时报 -bash: brew: command not found

通过修改~/.zshrc ,~/.zprofile 配置文件,在其中增加环境变量

编辑~/.zshrc 文件,增加以下环境变量

#brew config

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottle

最后 source  ~/.zshrc 使配置文件生效

再编辑 ~/.zprofile 文件,增加以下环境变量

#brew config

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles

最后source ~/.zshrc 使配置文件生效

现在验证一下,输入brew -v

已经不报 -bash: brew: command not found 的问题

现在开始安装scrcpy 

按照给出的提示安装:arch -arm64 brew install scrcpy

安装过程中还是报错

解决办法是重新安装Homeblew

在国内使用以下地址安装:

  • (完全体 推荐 )常规安装脚本 :

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

  安装成功 但还需要重启终端 或者 运行 source /Users/liqinzhang/.bash_profile   否则国内地址无法生效

然后接着安装 brew install scrcpy

报错:

==> Installing scrcpy dependency: brotli

fatal: not in a git directory

Error: Command failed with exit 128: git

解决办法:

brew -v 查看会有两个提示,提示用户设置 homebrew-cask 和 homebrew-core 的文件路径为设置为safe.directory

使用如下命令解决:

 git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask

接着再brew install scrcpy  就可以安装成功了

有adb环境的情况下就可以使用scrcpy进行手机录屏了

猜你喜欢

转载自blog.csdn.net/weixin_38383706/article/details/131048160