homebrew换源
时间: 2023-11-07 09:05:59 浏览: 122
好的,关于homebrew换源,你可以按照以下步骤进行操作:
1. 首先备份原有的brew源:
```
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
```
2. 替换为清华大学的源:
```
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
```
3. 更新brew并重置homebrew-core:
```
brew update
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
```
4. 最后再次更新brew即可。
```
brew update
```
相关问题
homebrew 换源
### 更改 Homebrew 镜像源
为了提高在中国大陆地区使用 Homebrew 的效率,可以将默认的镜像源更改为国内的镜像源。这可以通过修改 Git 远程仓库地址以及 Homebrew 自身的一些设置来实现。
#### 修改 Homebrew 主库和核心库的远程 URL 地址
对于已经安装过 Homebrew 的用户来说,先切换到主目录下的 `.git` 文件夹中找到 `config` 文件并备份它:
```bash
cd $(brew --repo)/.git/
cp config config.bak
```
接着执行如下命令以替换为清华大学提供的镜像源[^2]:
```bash
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
```
同样的操作也适用于 Homebrew/core 和其他 taps(插件),比如 Homebrew/cask:
```bash
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
```
#### 更新本地缓存
完成上述更改之后,建议清理旧版本的软件包数据,并更新 Homebrew 列表以便立即生效新的配置:
```bash
brew update
brew cleanup
```
通过以上步骤就可以成功地把 Homebrew 及其依赖项指向更快捷稳定的国内服务器了[^4]。
[email protected] 在 Homebrew 换源地址
MySQL 5.7版本通过Homebrew安装时,默认使用的源可能不是最新的,如果你想更换源地址以获取更稳定或更快的更新,可以按照以下步骤操作:
1. **备份当前环境**:
在更换源之前,最好先备份当前的Homebrew配置,以防万一。可以在终端输入:
```
brew config > ~/.backup/brew_config_before_change
```
2. **修改Homebrew仓库**:
打开Homebrew的配置文件`~/.bash_profile`, `~/.zshrc` 或者 `~/.bashrc`(取决于你的shell),添加以下行来指定新的源镜像:
```bash
# 更换为阿里云或其他官方推荐的国内源
export HOMEBREW_URL=https://mirrors.aliyun.com/homebrew/
export BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/bottles
```
然后运行:
```
source ~/.bash_profile
```
3. **确认更改**:
使用`brew doctor`检查新设置是否有效,并解决可能出现的问题。
4. **安装MySQL**:
如果你想安装MySQL 5.7,现在可以使用`brew install [email protected]`命令了。
注意:替换源可能导致软件包的更新速度、性能或兼容性有所变化,所以在切换前确保你了解并接受潜在的风险。
阅读全文
相关推荐
















