更新 2021-1.20
可以直接用下边的脚本进行安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
https://www.cpming.top/p/install-homebrew-in-china
https://zhuanlan.zhihu.com/p/341831809
Homebrew
-
是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件
-
基于Ruby的
-
把软件包安装到/usr/local/Cellar/
下,然后在/usr/local/bin
下建立符号链接
-
核心概念
词汇 | 含义 |
---|
formula (e) | 安装包的描述文件,formulae 为复数 |
cellar | 安装好后所在的目录 |
keg | 具体某个包所在的目录,keg 是 cellar 的子目录 |
bottle | 预先编译好的包,不需要现场下载编译源码,速度会快很多;官方库中的包大多都是通过 bottle 方式安装 |
tap | 下载源,可以类比于 Linux 下的包管理器 repository✨ |
cask | 安装 macOS native 应用的扩展,你也可以理解为有图形化界面的应用。✨ |
bundle | 描述 Homebrew 依赖的扩展 |
-
安装
$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
$git clone git://mirrors.ustc.edu.cn/homebrew-cask.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --depth=1
$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://github.com/Homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
$brew update
$brew install node
-
可能出现的错误:
Failed to connect to raw.githubusercontent.com port 443: Connection refused error:
$sudo vi /etc/hosts
140.82.114.3 github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.110.153 assets-cdn.github.com
140.82.114.3 gist.github.com
199.232.28.133 raw.githubusercontent.com
199.232.28.133 gist.githubusercontent.com
199.232.28.133 cloud.githubusercontent.com
199.232.28.133 camo.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
$ brew doctor
$ cd "$(brew --repo)"
$ git fetch
$ git reset --hard origin/master
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git fetch
$ git reset --hard origin/master
$ 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://github.com/Homebrew/homebrew-core.git
$git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
$git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://github.com/Homebrew/homebrew-cask-fonts.git
$git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://github.com/Homebrew/homebrew-cask-drivers.git
$brew update
$echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/linuxbrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
-
复原官方源
$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
$git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://github.com/Homebrew/homebrew-cask-fonts.git
$git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://github.com/Homebrew/homebrew-cask-drivers.git
-
常用命令
$brew search git
$brew install git
$brew rm $FORMULA
$brew uninstall --force $FORMULA
$brew info git
$brew deps --installed --tree
$brew update
$brew outdated
$brew upgrade
$brew cleanup
$brew list
$brew uninstall git
$brew cleanup
$brew pin $FORMULA
$brew unpin $FORMULA
$brew cask install 应用名称
$ brew tap homebrew/cask-fonts
$ brew cask install font-inconsolata
$brew tap homebrew/cask-drivers
$brew cask install xbox360-controller-driver-unofficial
-
常用安装
$brew cask install cakebrew
$brew tap jimbojsb/launchrocket
$brew cask install launchrocket
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)