MacOS下brew切换为国内源

这篇具有很好参考价值的文章主要介绍了MacOS下brew切换为国内源。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

简介

Homebrew 是一款自由及开放源代码的软件包管理系统,用以简化 macOS linux 系统上的软件安装过程。它拥有安装、卸载、更新、查看、搜索等很多实用的功能,通过简单的一条指令,就可以实现包管理,十分方便快捷。
Homebrew 主要有四个部分组成: brewhomebrew-corehomebrew-bottleshomebrew-cask

名称 说明
brew Homebrew 源代码仓库
homebrew-core Homebrew 核心软件仓库
homebrew-bottles Homebrew 预编译二进制软件包
homebrew-cask 提供 macOS 应用和大型二进制文件

查看当前源

# 查看 brew.git 当前源
$ cd "$(brew --repo)" && git remote -v
# 查看 homebrew-core.git 当前源
$ cd "$(brew --repo homebrew/core)" && git remote -v
# 查看 homebrew-cask.git 当前源
$ cd "$(brew --repo homebrew/cask)" && git remote -v

替换为阿里源

# 修改 brew.git 为阿里源
$ git -C "$(brew --repo)" remote set-url origin <https://mirrors.aliyun.com/homebrew/brew.git>

# 修改 homebrew-core.git 为阿里源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.aliyun.com/homebrew/homebrew-core.git>

# 修改 homebrew-cask.git 为阿里源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin <https://mirrors.aliyun.com/homebrew/homebrew-cask.git>

# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

替换为清华源

# 替换各个源
$ git -C "$(brew --repo)" remote set-url origin <https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git>
$ git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git>
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin <https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git>

# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

替换为中科大源

# 替换各个源
$ git -C "$(brew --repo)" remote set-url origin <https://mirrors.ustc.edu.cn/brew.git>
$ git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.ustc.edu.cn/homebrew-core.git>
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin <https://mirrors.ustc.edu.cn/homebrew-cask.git>

# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

重置为官方源

# 重置 brew.git 为官方源
$ git -C "$(brew --repo)" remote set-url origin <https://github.com/Homebrew/brew.git>

# 重置 homebrew-core.git 为官方源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin <https://github.com/Homebrew/homebrew-core.git>

# 重置 homebrew-cask.git 为官方源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin <https://github.com/Homebrew/homebrew-cask.git>

# zsh 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置
$ vi ~/.zshrc
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx

# bash 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置
$ vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx

# 刷新源
$ brew update

参考

https://zhuanlan.zhihu.com/p/613611678文章来源地址https://www.toymoban.com/news/detail-731066.html

到了这里,关于MacOS下brew切换为国内源的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • macOS 下使用 brew 命令安装 Node.js

    👨🏻‍💻 热爱摄影的程序员 👨🏻‍🎨 喜欢编码的设计师 🧕🏻 擅长设计的剪辑师 🧑🏻‍🏫 一位高冷无情的编码爱好者 大家好,我是 DevOps 工程师 欢迎分享 / 收藏 / 赞 / 在看! 输入以下命令以查找已安装的 Node.js 版本 如果显示了 Node.js 的版本号,表示 Node.js 已安装

    2024年02月08日
    浏览(32)
  • 【开发环境】macOS中包管理器brew的使用入门

     官网:Homebrew — The Missing Package Manager for macOS (or Linux) 所以,它是个包管理器,就像Linux系统的yum、apt-get神器,brew是MacOS系统中的神器。可以通过brew来安装大部分软件。 安装的软件都来源于官网,安全。 brew会管理软件的依赖和库,在不造成冗余的同时,大大缩短软件包的

    2024年01月25日
    浏览(32)
  • 在MacOS 上 使用brew 部署C++ gcc编译环境

    brew包管理工具能够帮助我们更好的管理电脑中的各种工具 再尝试了很多次下载之后发现,需要使用到国内的包进行下载安装,不要使用官网的链接进行直接下载,很大可能会导致下载失败 按照提示,需要重启Terminal或者输入 输入后提示 原因可能是没有安装xcode–select 按照提

    2024年02月05日
    浏览(26)
  • Mac上brew切换国内源【极简方案】

    下载一些开源包如telnet时,通过brew下载经常由于网络不通,导致下载失败。所以mac用户最好一次性设置brew为国内源。 极简四步,换Homebrew的镜像源为阿里云镜像,依次在终端执行以下几步: 1、cd “$(brew --repo)” 2、git remote set-url origin https://mirrors.aliyun.com/brew.git 3、cd “$(br

    2024年02月07日
    浏览(30)
  • 【macOS 系列】下载brew或其他依赖包提示连接超时的问题解决

    在下载brew或其他依赖包提示连接超时 错误信息: 最简单的方式,就是修改DNS:为 114.114.114.114 或者 8.8.8.8 就好。 如何修改: 右上角-网络-网络偏好设置-高级: 最终的效果: 如果你在web前端开发、面试、前端学习路线有困难可以加我V:imqdcnn。免费答疑,行业深潜多年的技

    2024年02月12日
    浏览(30)
  • Mac系统brew报错“The GitHub credentials in the macOS keychain may be invalid”解决

    报错信息如下: $ brew search nginx Warning: Error searching on GitHub: GitHub API Error: Requires authentication The GitHub credentials in the macOS keychain may be invalid. Clear them with:   printf \\\"protocol=httpsnhost=github.comn\\\" | git credential-osxkeychain erase Create a GitHub personal access token: https://github.com/settings/tokens/new?sco

    2024年02月10日
    浏览(42)
  • macOS搭建PHP开发环境(brew安装nginx、mysql 和多版本php,并配置多个php同时运行的环境)

    由于homebrew主库中没有PHP7.2 之前的版本,并且7.2,7.3版本也被标记成过时版本;所以需要先挂在第三方的扩展,具体操作如下: php5.6 php7.3 php7.4 php8.2 默认新版8以上直接安装 sudo vim /usr/local/etc/php/5.6/php-fpm.conf  下的: 注意:5.6版本的配置文件路径和其他版本不一样 listen = 127

    2024年02月04日
    浏览(52)
  • MacOS上配置docker国内镜像仓库地址

    docker官方镜像仓库网速较差,我们需要设置国内镜像服务 我的MacOS docker版本如下 点击Settings 点击Docker Engine 修改配置文件,添加 registry-mirrors 参考阿里云的镜像加速文档:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors 上述链接需要登录阿里云账号获取专属用户的镜像加速器地

    2024年02月09日
    浏览(40)
  • docker安装并使用国内源(Linux、Windows、macOS)

    Windows系统安装Docker并配置国内源 安装 Docker Desktop : 访问Docker官网(https://www.docker.com/products/docker-desktop)下载适用于Windows的Docker Desktop安装包并安装。 配置国内镜像源 : 在Docker Desktop中点击顶部菜单栏的“ whale icon - Preferences - Daemon”(Windows旧版本可能是“Settings”)。 在

    2024年04月22日
    浏览(23)
  • win10系统切换到macOS,开发环境与软件资源,目录清单

    1、因为考研自习室或学校图书馆,随身携带游戏本(全能本)受限于 不插电源就不续航和掉性能,以及风扇噪音非常大,以及发热很烫 等问题。 2、所以想考虑给主力机换个mac,目前暂定是买啦 m1pro(10+16)+16g+1t 的版本,因为原来的电脑空间用了非常多,不得不删掉一些东西

    2024年02月15日
    浏览(35)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包