homebrew:常用命令(Homebrew 4.0.10-119)
一,brew常用的命令
1,查看brew下载文件的缓存目录
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew --cache
/Users/liuhongdi/Library/Caches/Homebrew
2,查看brew的安装目录
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew --prefix
/usr/local
也可以:
liuhongdi@liuhongdideMacBook-Pro poem % cd "$(brew --repo)" liuhongdi@liuhongdideMacBook-Pro Homebrew % pwd /usr/local/Homebrew
3,列出已安装的软件
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew list ==> Formulae brotli c-ares ca-certificates icu4c libnghttp2 libuv node openssl@1.1
4,安装node
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew install node
安装完成后查看版本:
liuhongdi@liuhongdideMacBook-Pro Homebrew % node -v v19.8.1
5,查看已安装软件的信息:
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew info node ==> node: stable 19.8.1 (bottled), HEAD Platform built on V8 to build network applications https://nodejs.org/ /usr/local/Cellar/node/19.8.1 (2,357 files, 56.7MB) * Poured from bottle using the formulae.brew.sh API on 2023-04-01 at 12:47:34 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/node.rb License: MIT ==> Dependencies Build: pkg-config ✘, python@3.11 ✘ Required: brotli ✔, c-ares ✔, icu4c ✔, libnghttp2 ✔, libuv ✔, openssl@1.1 ✔ ==> Options --HEAD Install HEAD version ==> Analytics install: 8,413 (30 days), 930,971 (90 days), 4,931,720 (365 days) install-on-request: 7,695 (30 days), 815,366 (90 days), 4,361,602 (365 days) build-error: 32 (30 days)
6,查看已安装软件的依赖:
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew deps --installed --tree node node ├── brotli ├── c-ares ├── icu4c ├── libnghttp2 ├── libuv └── openssl@1.1 └── ca-certificates
7,卸载软件
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew uninstall node
8,搜索:
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew search node ==> Formulae libbitcoin-node llnode node-build node@10 node@14 node@18 nodebrew nodenv linode-cli node node-sass node@12 node@16 node_exporter nodeenv ode ==> Casks capslocknodelay nodebox nodeclipse If you meant "node" specifically: It was migrated from homebrew/cask to homebrew/core.
说明:
「Formulae」:命令行工具、开发库、字体、插件等不含 GUI 界面的软件
「Cask」:含有 GUI 图形化界面的软件,如 Google Chrome、FireFox 、Atom 等
9,安装时指定版本:
liuhongdi@liuhongdideMacBook-Pro Homebrew % brew install node@18 ==> Downloading https://formulae.brew.sh/api/formula.jws.json #=#=# ==> Fetching node@18 ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/node%4018-18.15.0.monterey.bottle.1.tar.gz ######################################################################## 100.0% ==> Pouring node@18-18.15.0.monterey.bottle.1.tar.gz ==> Caveats node@18 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have node@18 first in your PATH, run: echo 'export PATH="/usr/local/opt/node@18/bin:$PATH"' >> ~/.zshrc For compilers to find node@18 you may need to set: export LDFLAGS="-L/usr/local/opt/node@18/lib" export CPPFLAGS="-I/usr/local/opt/node@18/include" ==> Summary 🍺 /usr/local/Cellar/node@18/18.15.0: 2,343 files, 56.6MB ==> Running `brew cleanup node@18`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). liuhongdi@liuhongdideMacBook-Pro Homebrew % node -v zsh: command not found: node liuhongdi@liuhongdideMacBook-Pro Homebrew % /usr/local/opt/node@18/bin/node -v v18.15.0 liuhongdi@liuhongdideMacBook-Pro Homebrew % echo 'export PATH="/usr/local/opt/node@18/bin:$PATH"' >> ~/.zshrc liuhongdi@liuhongdideMacBook-Pro Homebrew % source ~/.zshrc liuhongdi@liuhongdideMacBook-Pro Homebrew % node -v v18.15.0
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/06/05/homebrew-chang-yong-ming-ling-homebrew-4-10119/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,查看homebrew的版本:
liuhongdi@liuhongdideMacBook-Pro poem % brew --version Homebrew 4.0.10-119-g931327d Homebrew/homebrew-core (git revision 3d8b912faa5; last commit 2023-04-01) Homebrew/homebrew-cask (git revision 5d24927a9d; last commit 2023-04-01)