Homebrew|介绍以及安装和卸载
介绍
官方:https://brew.sh
HomeBrew 兼得 Fink 和 MacPorts 的特点,对于有已编译的二进制包则直接下载安装,没有的就下载源码进行编译安装。它也可以通过配置参数达到仅二进制包分发或全部编译安装的效果,可以说功能强大。同时支持扩展,最著名且实用的可能是 Caskroom(支持分发 .dmg 或 .pkg 格式的 App 安装包)。
HomeBrew 为了避免 sudo 权限执行,允许了 User 权限访问系统的部分关键目录来完成安装。这是一把双刃剑,需要妥善管理以避免被恶意软件应用。
安装 Homebrew
国内用户推荐使用清华大学的镜像源,以解决速度问题。举例:
- 下载安装脚本
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git
(官方的安装脚本:https://raw.githubusercontent.com/Homebrew/install/master/install.sh ) - 编辑其中
编辑文件 install/install.sh 内容,将其中的BREW_REPO="https://github.com/Homebrew/brew"
改成:BREW_REPO="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
- 运行 install.sh 以安装 Homebrew
cd install # brew 运行时会从 Homebrew bottles 中拉取一个包 export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles # 如果是 Linux 用户,请使用以下这句命令 # export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git bash install.sh
安装时可能遇到的问题
- 报错:
curl: (7) Failed to connect to raw.githubusercontent.com
解决方法:修改 hosts 文件,添加:199.232.28.133 raw.githubusercontent.com
卸载
参考官方指导:https://github.com/Homebrew/install
相关参考:https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
(正文结束。芝士就是力量!)