标签: Brew

  • brew install 时出现 fatal: not in a git directory Error: Command failed with exit 128: git 解决办法 图文教程

    brew install 时出现 fatal: not in a git directory Error: Command failed with exit 128: git 解决办法 图文教程

    fatal: not in a git directory Error: Command failed with exit 128: git
    执行​​ brew install cmake​​ 遇到了下面的错误

    Already downloaded: /Users/kingcall/Library/Caches/Homebrew/downloads/b7ef8d6eb909e967d072212c62e71bfb8e94e6227ae2d3567bbabcc561fd9fff–cmake-3.21.4.bottle_manifest.json
    ==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:c86a0bb0e37c293e2d4475519d28f2784c430e871f74969a1a2afeb64b540a7d
    Already downloaded: /Users/kingcall/Library/Caches/Homebrew/downloads/1e8ca69a4444469a3f380baf4e514072d4d0f0b5d5ccd43b8ce3eb68081eff3d–cmake–3.21.4.arm64_monterey.bottle.tar.gz
    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


    之后再执行 ​​arch -arm64 brew install cocoapods​​ 即可

    如果遇到上面的错误则根据提示执行

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

    然后再次执行​​arch -arm64 brew install cocoapods​​ 即可成功。

    执行成功后我们再次执行我们的安装命令 ​​brew install cmake

  • MacOS brew upgrade 出现  Error: Permission denied @ apply2files – /usr/local/lib/docker/cli-plugins

    MacOS brew upgrade 出现 Error: Permission denied @ apply2files – /usr/local/lib/docker/cli-plugins

    问题描述

    我们在MacOS中使用 brew upgrade --verbose 升级系统时出现了如下错误

    Error: Permission denied @ apply2files – /usr/local/lib/docker/cli-plugins

    解决办法

    sudo chown -R $(whoami) $(brew --prefix)/*
  • 让 Homebrew 走代理更新

    让 Homebrew 走代理更新

    之前我们说过,由于国内网络进一步恶劣,使用 brew 也要Mac下的brew切换到国内的镜像源,但是这样的方法治标不治本,更新是快了,可是下载还是一样。

    结果就是导致大部分的更新都需要去下载源码然后本地编译,运气差一点的干脆源码也下载不下来,每次都要取消然后重试,不停地手工重复。

    ——如果能让终端命令走代理就好了。

    是的,你可能想到了什么比如 proxychains-ng 这类的软件,其实不用,因为 brew 是支持全局代理的,我们只需要在当前环境当中加入代理配置即可。

    在终端中输入如下代码:

    export ALL_PROXY=socks5://127.0.0.1:1080

    如果说你想要 brew 永久如此,我们就需要将环境变量写入终端的配置当中,这取决于你的终端,如果是默认的 bash,则写入 ~/.bash_profile ,如果是 zsh,则写在 ~/.zshrc  里。

    或者直接用如下语句来将命令直接导入到配置文件里。

    echo export ALL_PROXY=socks5://127.0.0.1:1080 >> ~/.bash_profile 

    zsh终端(MAC OS下切换默认终端为zsh 图文教程)

    echo export ALL_PROXY=socks5://127.0.0.1:1080 >> ~/.zsh_profile

    这样,Homebrew 就能通过代理来更新了,速度嗖嗖的。:)

  • MacOS brew  fatal: unable to access ‘https://github.com/Homebrew/homebrew-core/’

    MacOS brew fatal: unable to access ‘https://github.com/Homebrew/homebrew-core/’

    问题描述

    MacOS在brew update更新时报错:

    ==> Tapping homebrew/core
    Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…
    fatal: unable to access ‘https://github.com/Homebrew/homebrew-core/’: LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
    Error: Failure while executing; git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1 exited with 128.
    Error: Failure while executing; /usr/local/bin/brew tap homebrew/core exited with 1.

    解决方法

    // 执行下面这句命令,更换为中科院的镜像:
    git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

    Mac下的brew切换到国内的镜像源

    // 更新
    brew update

  • Mac下的brew切换到国内的镜像源

    Mac下的brew切换到国内的镜像源

    homebrew虽好,但是GFW的原因,你懂的,用起来非常的。。慢 brew update也永远更新不上 今天要装个mongodb,实在受不了了,换可中科大的源,然后飞快。   直接上链接

    homebrew主要分两部分:git repo(位于GitHub)和二进制bottles(位于bintray),这两者在国内访问都不太顺畅。可以替换成国内的镜像,git repo国内镜像就比较多了,可以自行查找,提供二进制镜像的:

    • 中科大镜像(中科大的镜像做的太好了!)

    替换homebrew默认源 [LUG@USTC]
    替换homebrew bottles默认源 [LUG@USTC]

    当然,也可以不打开链接,直接按照下面的方法在终端里敲即可.

    替换homebrew默认源

    cd "$(brew --repo)"
    git remote set-url origin git://mirrors.ustc.edu.cn/brew.git

    Homebrew Bottles源

    Homebrew Bottles是Homebrew提供的二进制代码包,目前镜像站收录了以下仓库:

    • homebrew/homebrew-core
    • homebrew/homebrew-dupes
    • homebrew/homebrew-games
    • homebrew/homebrew-gui
    • homebrew/homebrew-python
    • homebrew/homebrew-php
    • homebrew/homebrew-science
    • homebrew/homebrew-versions
    • homebrew/homebrew-x11

    使用方法

    bash用户

    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile

    zsh用户

    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc

    完成上面两个源的替换后,记得brew update更新一下。

    更新系统,并显示进度

    brew upgrade --verbose
WeChat
↑