mac安装Homebrew 和使用

一、Homebrew是什么

Homebrew
在这里插入图片描述
Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。

援引官方的一句话:又提示缺少套件啦?别担心,Homebrew 随时守候。Homebrew —— OS X 不可或缺的套件管理器。

二、Homebrew安装

按照命令安装

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

报错
在这里插入图片描述
加权限

sudo chgrp -R admin /usr/local 
sudo chmod -R g+w /usr/local

再次安装

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

安装成功

三、修改镜像源

查看镜像源

查看当前Homebrew 镜像源

brew.git镜像源

git -C "$(brew --repo)" remote -v

homebrew-core.git镜像源

git -C "$(brew --repo homebrew/core)" remote -v

homebrew-cask.git镜像源

git -C "$(brew --repo homebrew/cask)" remote -v 

国内镜像地址

科大: https://mirrors.ustc.edu.cn
阿里: https://mirrors.aliyun.com/homebrew/

科大真香实例:

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

修改环境变量

vi /etc/profile
//在最下面添加
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/
//更新
brew update

如果需要恢复原有镜像源的话(国内镜像源突然不能用了或版本不够新)

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

删除/etc/profile环境变量中HOMEBREW_BOTTLE_DOMAIN

brew update

如果可以了下面的就不用看了

如果不行的话可以依次尝试以下命令

brew doctor
brew update-reset
brew update

参考地址
中文官网地址:https://brew.sh/index_zh-cn.html
修改镜像:https://zhuanlan.zhihu.com/p/102760018

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值