新增homebrew安装及问题处理

pull/4/head
liruyu 2 years ago
parent af54b54d4b
commit 2ef5adb443

@ -1481,6 +1481,126 @@ Mac 键盘符号和修饰键说明
# homebrew
## 自动安装homebrew
```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
参考地址https://brew.sh/
## 手动安装homebrew
使用homebrew脚本安装的时候 会因为访问问题失败,此时通过手动安装 使用镜像地址可以解决:
```shell
# 创建安装文件夹
sudo mkdir /usr/local/Homebrew
# 直接从镜像地址git clone
sudo git clone https://mirrors.ustc.edu.cn/brew.git /usr/local/Homebrew
# 创建链接,如果已经存在 则删除后再创建
sudo ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew
# 创建core文件夹 并且完成core的clone
sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
sudo git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
# 调整权限,并运行更新
sudo chown -R $(whoami) /usr/local/Homebrew
brew update
# 更新环境变量(zsh或bash)
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
```
## 解决brew安装慢
### 替换brew.git仓库地址
```bash
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
```
还原
```bash
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
```
### 替换homebrew-core.git仓库地址
```bash
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
```
还原
```bash
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
```
### 替换homebrew-bottles访问地址
这个步骤跟你的 macOS 系统使用的 shell 版本有关系,先来查看当前使用的 shell 版本
```bash
echo $SHELL
/bin/zsh
```
#### zsh替换成阿里巴巴的homebrew-bottles访问地址
```bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
```
还原
```bash
vi ~/.zshrc
# 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置
source ~/.zshrc
```
#### bash替换成阿里巴巴的homebrew-bottles访问地址
```bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
```
还原
```bash
vi ~/.bash_profile
# 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置
source ~/.bash_profile
```
配置完后再去安装下某些工具和module时就能发现畅快无比了。
# Product
## Axure RP

Loading…
Cancel
Save