一、什么是 Homebrew ?
Homebrew 官网有一句话:Homebrew complements macOS. ( Homebrew 使 macOS 更完整。)Homebrew 是 macOS 的套件管理工具,是高效下载软件的一种方法,相当于 Linux 下的 yum
、apt-get
神器,用于下载存在依赖关系的软件包。通俗地说,Homebrew 是类似于 Mac App Store 的一个软件商店。
二、Homebrew 的好处
通过 Homebrew 下载的软件都来自于官网,绝对放心软件的安全性。而且它尽可能地利用系统自带的各种库,使得软件包的编译时间大大缩短,基本上不会造成冗余。
三、怎么安装
输入以下代码:
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
不用官方的,新Mac弃用ruby改为bash
% /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/var/homebrew
/opt/homebrew/var/homebrew/linked
/opt/homebrew/Cellar
/opt/homebrew/Caskroom
/opt/homebrew/Frameworks
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew
==> /usr/bin/sudo /usr/sbin/chown root:wheel /opt/homebrew
==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /bin/chmod g+rwx /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/sbin/chown carl /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/sbin/chown -R carl:admin /opt/homebrew
==> /usr/bin/sudo /bin/mkdir -p /Users/carl/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/carl/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown -R carl /Users/carl/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 175016, done.
remote: Counting objects: 100% (175016/175016), done.
remote: Compressing objects: 100% (40688/40688), done.
remote: Total 175016 (delta 130389), reused 174895 (delta 130342)
Receiving objects: 100% (175016/175016), 44.62 MiB | 8.24 MiB/s, done.
Resolving deltas: 100% (130389/130389), done.
From https://mirrors.ustc.edu.cn/brew
* [new branch] master -> origin/master
* [new tag] 3.0.2 -> 3.0.2
remote: Enumerating objects: 7531, done.
remote: Counting objects: 100% (7531/7531), done.
remote: Compressing objects: 100% (1581/1581), done.
remote: Total 7531 (delta 5798), reused 7531 (delta 5798)
Receiving objects: 100% (7531/7531), 1.61 MiB | 6.74 MiB/s, done.
Resolving deltas: 100% (5798/5798), completed with 737 local objects.
From https://mirrors.ustc.edu.cn/brew
* [new tag] 1.1.0.1 -> 1.1.0.1
* [new tag] 1.1.2.1 -> 1.1.2.1
* [new tag] 1.2.7 -> 1.2.7
* [new tag] 1.2.8 -> 1.2.8
* [new tag] backup/activesupport-23-38-09 -> backup/activesupport-23-38-09
* [new tag] backup/brew-cask-style-14-54-55 -> backup/brew-cask-style-14-54-55
* [new tag] backup/create-cache-00-29-47 -> backup/create-cache-00-29-47
* [new tag] backup/days-03-02-52 -> backup/days-03-02-52
* [new tag] backup/days-03-02-59 -> backup/days-03-02-59
* [new tag] backup/days-19-30-23 -> backup/days-19-30-23
* [new tag] backup/gpg-verification-01-53-16 -> backup/gpg-verification-01-53-16
* [new tag] backup/remove-popen-read-19-56-50 -> backup/remove-popen-read-19-56-50
* [new tag] backup/remove-popen-read-20-00-21 -> backup/remove-popen-read-20-00-21
HEAD is now at 787e6cb75 Merge pull request #10667 from dtrodrigues/pr-man
==> Tapping homebrew/core
remote: Enumerating objects: 915097, done.
remote: Total 915097 (delta 0), reused 0 (delta 0)B | 8.79 MiB/s
Receiving objects: 100% (915097/915097), 358.19 MiB | 8.78 MiB/s, done.
Resolving deltas: 100% (626173/626173), done.
From https://mirrors.ustc.edu.cn/homebrew-core
* [new branch] master -> origin/master
HEAD is now at ff20a31ae0 gh: update 1.6.2 bottle.
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:
- Add Homebrew to your PATH in /Users/carl/.zprofile:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/ca/.zprofile
eval $(/opt/homebrew/bin/brew shellenv)
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
ca@CadeMacBook- homebrew
# To activate this environment, use
# $ conda activate py39t
# To deactivate an active environment, use
# $ conda deactivate
最后看到==> Installation successful!
就说明安装成功了。
但执行brew -v 不显示版本号
% brew -v
zsh: command not found: brew
需更改系统环境变量,将/opt/homebrew/bin加入$PATH
由于新Mac默认shell为zsh,配置文件为:.zshrc
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home"
CLASS_PATH="$JAVA_HOME/lib"
BREW_HOME='/opt/homebrew'
M2_HOME=/Users/Documents/maven/apache-maven-3.6.3
PATH="$JAVA_HOME/bin":"$M2_HOME/bin":"$BREW_HOME/bin":$PATH
export JAVA_HOME
export BREW_HOME
export M2_HOME
export CLASS_PATH
export PATH
验证:
% brew -v
Homebrew 3.0.2
Homebrew/homebrew-core (git revision ff20a; last commit 2021-02-23)
% brew help
Example usage:
brew search [TEXT|/REGEX/]
brew info [FORMULA...]
brew install FORMULA...
brew update
brew upgrade [FORMULA...]
brew uninstall FORMULA...
brew list [FORMULA...]
Troubleshooting:
brew config
brew doctor
brew install --verbose --debug FORMULA
Contributing:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
Further help:
brew commands
brew help [COMMAND]
man brew
https://docs.brew.sh
// 啰嗦模式查看更新进度
brew update --verbose
删除brew使用代码:
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall)"
相关文章: