Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。
安装
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
但是个人觉得可能是国内网络的问题经常下载并不是很顺利,经常443拒绝访问
如何解决
- 在任意浏览器输入https://raw.githubusercontent.com/Homebrew/install/master/install
保存网页的内容于任意路径,并命名为brew_install.rb
- 进入
brew_install.rb
保存的路径,在终端输入指令
ruby brew_install.rb
- 等待安装完成
如何使用
- 安装你所需要的包
brew install <packageName>
brew install react-native-cli
- 卸载包
brew uninstall <packageName>
- 查询可用包
brew search <packageName>
- 查看已安装包列表
brew list
- 更新Homebrew
brew update
- Homebrew帮助信息
brew -h
- 其他brew命令
brew install git // 使用brew安装软件
brew home // 用浏览器打开brew的官方网站
brew info // 显示软件信息
brew deps // 显示包依赖
brew和brew cask区别
- brew 装的主要是 command line tool
- brew cask主要用来下载一些带界面的应用软件,下载好后会自动安装,并能在mac中直接运行使用
MacBook Pro M1芯片问题
安装成功后会出现command not found: brew
字样,无法使用
==> /usr/bin/sudo /usr/sbin/chown joeliu:admin /opt/homebrew
==> Downloading and installing Homebrew...
HEAD is now at 4a90a5a5d Merge pull request #10199 from reitermarkus/check-https-content
Already up-to-date.
Warning: /opt/homebrew/bin is not in your PATH.
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
~ % brew help
zsh: command not found: brew
在终端输入即可解决问题
// 二选一
export PATH="/opt/homebrew/bin:$PATH"
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> $HOME/.zshrc
参考文章
Mac必备神器Homebrew
M1 command not found: brew
网友评论