安装问题

1、按照/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"这种方式安装brew,会因为墙的原因无法下载脚本,会报以下的错误: curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

可以通过github直接下载源码进行安装,网址:https://github.com/Homebrew/brew

也可以根据官网的说明文档进行安装:https://docs.brew.sh/Installation 复制mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew到terminal,进行安装。官网建议先cd /usr/local,再执行。

2、注意:安装完成后,由于PATH环境变量设置问题,无法直接调用,需要配置环境变量。

mac的shell有bashzsh(更新之后默认为zsh),分别对应于~/.bash_profile~/.zshrc,因此不要改错文件,在对应的配置文件中添加export PATH=/usr/local/homebrew/bin:$PATH就可以直接调用。 当然要先使配置文件生效:source ~/.bash_profilesource ~/.zshrc

下载速度问题

brew默认的下载源在国外,下载速度很慢,可以更换为国内的清华源或者中科大源,方式如下:

1、替换brew.git:

$ cd "$(brew --repo)"#首先设置好环境变量

中国科大:

$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

清华大学:

$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

2、替换homebrew-core.git:

$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

中国科大:

$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

清华大学:

$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

3、替换homebrew-bottles:
中国科大:

$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile $ source ~/.bash_profile

清华大学:

$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile $ source ~/.bash_profile

4、应用生效:

$ brew update

Categories: MacSoftware

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *