Homebrew常用安装卸载命令

翟淮晨
2023-12-01

Homebrew

安装Homebrew

Homebrew国内如何自动安装https://zhuanlan.zhihu.com/p/111014448

更新brew

上述方法安装后即自动更新
但用brew安装imagemagic时报错,可能还是更新问题
再次手动更新

rm -rf /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
brew update

关闭Homebrew自动更新

把如下代码加入shell配置文件中:

export HOMEBREW_NO_AUTO_UPDATE=true

再使其生效:
如在zsh中用:source ~/.zshrc
如在bash中用:source ~/.bashrc

brew常用命令

命令


which brew #展示brew的位置


brew search #列出brew支持的软件

brew search <package_name> #搜索



brew install <package_name> #安装软件

brew uninstall <package_name> #卸载软件



brew cu #升级所有过期软件

brew update #从服务器上拉取,并更新本地 brew 的包目录

brew upgrade <package_name> #更新软件

brew outdated #查看你的软件中哪些有新版本可用

brew cleanup #清理老版本。使用 `-n` 参数,不会真正执行,只是打印出真正运行时会做什么。


brew list #查看你安装过的包列表

brew list --versions #查看你安装过的包列表(包括版本号)


brew link <package_name> #将软件的当前最新版本软链到`/usr/local`目录下

brew unlink <package_name> #将软件在`/usr/local`目录下的软链接删除

brew info #显示软件的信息

brew deps #显示包依赖

brew --cache #获取brew缓存路径,将下载的文件放入缓存目录;

Homebrew cask

安装Homebrew cask

$ brew tap homebrew/cask
$ brew install cask

安装成功

==> Summary
  /usr/local/Cellar/cask/0.8.5: 16 files, 221.8KB, built in 3 seconds
==> Caveats
==> guile
Guile libraries can now be installed here:
    Source files: /usr/local/share/guile/site/3.0
  Compiled files: /usr/local/lib/guile/3.0/site-ccache
      Extensions: /usr/local/lib/guile/3.0/extensions

Add the following to your .bashrc or equivalent:
  export GUILE_LOAD_PATH="/usr/local/share/guile/site/3.0"
  export GUILE_LOAD_COMPILED_PATH="/usr/local/lib/guile/3.0/site-ccache"
  export GUILE_SYSTEM_EXTENSIONS_PATH="/usr/local/lib/guile/3.0/extensions"
==> unbound
To have launchd start unbound now and restart at startup:
  sudo brew services start unbound
==> gnutls
If you are going to use the Guile bindings you will need to add the following
to your .bashrc or equivalent in order for Guile to find the TLS certificates
database:
  export GUILE_TLS_CERTIFICATE_DIRECTORY=/usr/local/etc/gnutls/
==> emacs
To have launchd start emacs now and restart at login:
  brew services start emacs
Or, if you don't want/need a background service you can just run:
  emacs
==> cask
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cask

brew cask 安装与卸载软件

brew cask install <package_name>

会提示: Calling brew cask install is deprecated! Use brew install [–cask] instead. 也能装上。

下载pkg或dmg速度一般很慢,可以先找到brew下载安装软件后的存储地址,用其他方式下载后把文件放进去。

brew --cache  #获取brew缓存路径。

重新执行安装命令,brew会发现缓存中有了文件,就不去下载了。

brew cask 升级软件

安装cask update

 类似资料: