Mac安装homebrew
下载并安装homebrew的sh安装包
安装命令来自https://brew.sh/, 直接复制到命令行运行就可以
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
如果上述命令执行不了,就手动下载install.sh文件
,然后在命令行之行.sh文件
遇到Permission denied问题:参考https://blog.csdn.net/weixin_41770169/article/details/86664553
执行如下命令
chmod 777 install.sh
安装完成
安装完成后可能会出现warning
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
这表示brew没有被加入到环境变量中,因此需要添加环境变量
参考https://blog.csdn.net/tao_627/article/details/104856365
首先命令行执行,打开配置文件
vim ~/.bash_profile
这是用vim方式执行修改文件的命令,想要详细了解可以去搜索vim的命令用法, 我们要做的事情是
- 首先切换输入法到英文,点击i(表示正在insert文字)
- 将下述内容复制粘贴
export PATH=/opt/homebrew/bin:$PATH
- 首先按
esc
退出insert模式,然后按住shift ;
输入:
(表示接下来要执行命令),然后输入wq
(表示执行write的命令
后执行quite的命令
)。这步完成后,应该退出vim模式,返回到命令行页面 - 执行
source ~/.bash_profile
使命令生效 - 执行
brew -v
查看是否有输出,有输出版本号表示安装完毕
遇到问题:mac每次打开命令行都找不到brew
因为mac命令行用的zsh,但我配置的是bash。参考https://www.jianshu.com/p/407f0f9d8203
命令行输入echo $SHELL
,检查自己用的是什么,我的输出就是zsh
- 打开vim配置文件
vim ~/.zshrc
- 添加以下内容
if [ -f ~/.bash_profile ]; then
source ~/.bash_profile
fi
- 使zsh配置文件生效
source ~/.zshrc
意思就是每次调用zsh命令行的时候,都会执行一下bash_profile的配置,这样bash_profile里面的环境变量等一系列配置就都可以同步到当前命令行窗口了
修改镜像源
参考https://developer.aliyun.com/mirror/homebrew/, https://cloud.tencent.com/developer/article/1614039
查看当前源
# 查看 brew.git 当前源
# 有$打头的这一行是命令行输入
$ cd "$(brew --repo)" && git remote -v
# 下面的都表示该命令执行完成后的输出
origin https://github.com/Homebrew/brew.git (fetch)
origin https://github.com/Homebrew/brew.git (push)
# 查看 homebrew-core.git 当前源
$ cd "$(brew --repo homebrew/core)" && git remote -v
origin https://github.com/Homebrew/homebrew-core.git (fetch)
origin https://github.com/Homebrew/homebrew-core.git (push)
Bash 终端配置
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
Zsh 终端配置
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
恢复默认配置
出于某些场景, 可能需要回退到默认配置, 你可以通过下述方式回退到默认配置。
首先执行下述命令:
# 重置brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git
# 重置homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
我是懒狗直接截图了,图源自教程https://developer.aliyun.com/mirror/homebrew/
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgbggce
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13