美文网首页
mac更换brew源

mac更换brew源

作者: bychannel | 来源:发表于2020-10-27 08:59 被阅读0次

    前言

    最近想在mac上也安装一个NeoVim来用一下,不料 brew install neovim 命令输入后一直卡在update,查阅相关的brew资料发现:brew的软件源托管在github上,刚好最近的github网络也不通畅,随根据文档说明将软件源进行了修改。

    国内的话有很多brew源可以选择,例如中科大镜像、清华镜像,亦或是商业云平台提供的镜像源,如阿里云brew

    操作阿里云提供的方法为例,具体如下操作:

    bash终端使用

    # 替换brew.git:
    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
    
    # 替换homebrew-core.git:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
    
    # 应用生效
    brew update
    
    # 替换homebrew-bottles:
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
    
    source ~/.bash_profile
    

    zsh终端使用:

    # 替换brew.git:
    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
    
    # 替换homebrew-core.git:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
    
    # 应用生效
    brew update
    
    # 替换homebrew-bottles:
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
    
    source ~/.zshrc
    

    重置为官方源

    首先执行下述命令:

    # 重置brew.git:
    $ cd "$(brew --repo)"
    $ git remote set-url origin https://github.com/Homebrew/brew.git
    
    # 重置homebrew-core.git:
    $ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    $ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
    

    然后删掉 HOMEBREW_BOTTLE_DOMAIN 环境变量,刷新配置即可。

    将你终端文件~/.bash_profile或者~/.zshrcHOMEBREW_BOTTLE_DOMAIN行删掉, 并执行

    source ~/.bash_profile
    

    或者

    source ~/.zshrc
    

    相关文章

      网友评论

          本文标题:mac更换brew源

          本文链接:https://www.haomeiwen.com/subject/lanamktx.html