Site icon moneyslow.com

homebrew update 和 homebrew upgrade 的区别

homebrew是macOS(或 Linux)缺失的软件包的管理器

homebrew是macOS(或 Linux)缺失的软件包的管理器

我盲目地输入了上面的命令太久了,却没有理解它们的实际作用。本文将用简单的语言解释这些命令的作用。

当您按照官方文档说明(https://brew.sh/)第一次安装brew 时,您实际上将homebrew-core的git仓库(https://github.com/Homebrew/homebrew-core)下载到你的机器中/usr/local/Homebrew

该代码仓库包含所有ruby脚本,称为Formulas,它包含安装每个包的逻辑,您可以使用 brew 命令安装这些包。

因此,当你执行brew install 时,它会尝试在上述代码仓库下找到并运行它。

所以总结一下:
1、brew update 使用 GitHub 的最新代码更新自己的版本。
2、brew upgrade 更新实际已经安装的软件包到最新版本。

来实际操作一下:

% brew update
==> Updated Homebrew from 5babb4910 to 3.6.20 (79676ad20).
Updated 1 tap (laggardkernel/tap).
==> Outdated Formulae
aom              gettext          gnu-getopt       imath            libcbor          libheif          libraw           little-cms2      openssl@3        ruby-install     webp
ca-certificates  ghostscript      go               inetutils        libde265         libidn2          libssh           mysql-client     pcre2            sqlite           wget
fontconfig       git              hydra            jasper           libffi           libomp           libtiff          ncurses          python@3.9       tmux             xz
geckodriver      glib             imagemagick      jpeg-xl          libfido2         libpng           libunistring     openssl@1.1      readline         utf8proc

You have 43 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

The 3.6.0 release notes are available on the Homebrew Blog:
  https://brew.sh/blog/3.6.0
The 3.6.20 changelog can be found at:
  https://github.com/Homebrew/brew/releases/tag/3.6.20

看到了吧,homebrew update 更新了自己本身到最新版本。同时列出了可以升级的软件包。提示你如果想升级,可以用 brew upgrade ,想列出它们可以用 brew outdated。
再次执行 brew update:

% brew update
Already up-to-date.
brew自己的版本已经更新到最新了。

下面我们来列一下过期的软件包:

 % brew outdated
aom (3.4.0) < 3.5.0_2
ca-certificates (2022-04-26) < 2023-01-10
fontconfig (2.14.0) < 2.14.2
geckodriver (0.31.0) < 0.32.0
gettext (0.21) < 0.21.1
ghostscript (9.56.1) < 10.0.0
git (2.37.0) < 2.39.1
glib (2.72.2) < 2.74.5
gnu-getopt (2.38) < 2.38.1
go (1.18.3) < 1.19.5
hydra (9.3) < 9.4
imagemagick (7.1.0-43) < 7.1.0-60
imath (3.1.5) < 3.1.6
inetutils (2.3) < 2.4
jasper (3.0.5) < 4.0.0
jpeg-xl (0.6.1) < 0.8.0
libcbor (0.9.0) < 0.10.1
libde265 (1.0.8) < 1.0.10
libffi (3.4.2) < 3.4.4
libfido2 (1.11.0) < 1.12.0_1
libheif (1.12.0_1) < 1.14.2_1
libidn2 (2.3.2) < 2.3.4_1
libomp (14.0.6) < 15.0.7
libpng (1.6.37) < 1.6.39
libraw (0.20.2_2) < 0.21.1
libssh (0.9.6) < 0.10.4
libtiff (4.4.0) < 4.4.0_1
libunistring (1.0) < 1.1
little-cms2 (2.13.1) < 2.14
mysql-client (8.0.29) < 8.0.32
ncurses (6.3) < 6.4
openssl@1.1 (1.1.1q) < 1.1.1s
openssl@3 (3.0.5) < 3.0.7
pcre2 (10.40) < 10.42
python@3.9 (3.9.13_1) < 3.9.16
readline (8.1.2) < 8.2.1
ruby-install (0.8.3) < 0.8.5
sqlite (3.39.0) < 3.40.1
tmux (3.3a) < 3.3a_1
utf8proc (2.7.0) < 2.8.0
webp (1.2.2) < 1.3.0
wget (1.21.3) < 1.21.3_1
xz (5.2.5) < 5.4.1

看到了吧,和brew update 第一次执行提示的结果一样。

这次我们来仅仅更新一个软件包wget:

 % brew upgrade wget
Warning: You are using macOS 10.15.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from MacHomebrew on Twitter.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

==> Upgrading 1 outdated package:
wget 1.21.3 -> 1.21.3_1
==> Fetching dependencies for wget: libunistring, gettext, pkg-config, libidn2, ca-certificates and openssl@3
==> Fetching libunistring
==> Downloading https://ftp.gnu.org/gnu/libunistring/libunistring-1.1.tar.gz
######################################################################## 100.0%
==> Fetching gettext
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:aba2b94f406a9d8784bb08f9763440297c645a7ea99f4c4dbfeccb325053322a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:aba2b94f406a9d8784bb08f9763440297c645a7ea99f4c4dbfeccb325053322a?se=2023-01-31T02%3A05%3A00Z&sig=g0WXs0ad
######################################################################## 100.0%
==> Fetching pkg-config
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/blobs/sha256:80f141e695f73bd058fd82e9f539dc67471666ff6800c5e280b5af7d3050f435
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:80f141e695f73bd058fd82e9f539dc67471666ff6800c5e280b5af7d3050f435?se=2023-01-31T02%3A05%3A00Z&sig=mOOKr6Os
######################################################################## 100.0%
==> Fetching libidn2
==> Downloading https://ftp.gnu.org/gnu/libidn/libidn2-2.3.4.tar.gz
######################################################################## 100.0%
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-01-10
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:11fe9d0a98a2ac454fa1db95762a697c3340f46560ff27e5e9db8fdeb003f17e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:11fe9d0a98a2ac454fa1db95762a697c3340f46560ff27e5e9db8fdeb003f17e?se=2023-01-31T02%3A05%3A00Z&sig=8WA8ERV1
######################################################################## 100.0%
==> Fetching openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.0.7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:11f2d168758de4ac078c5799f2ce0fcc93e4f0c3d8b59e6f53eea700dfa02e83
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:11f2d168758de4ac078c5799f2ce0fcc93e4f0c3d8b59e6f53eea700dfa02e83?se=2023-01-31T02%3A05%3A00Z&sig=DvO8zMXh
######################################################################## 100.0%
==> Fetching wget
==> Downloading https://ftp.gnu.org/gnu/wget/wget-1.21.3.tar.gz
######################################################################## 100.0%
==> Upgrading wget
  1.21.3 -> 1.21.3_1

==> Installing dependencies for wget: libunistring, gettext, pkg-config, libidn2, ca-certificates and openssl@3
==> Installing wget dependency: libunistring
==> ./configure --prefix=/usr/local/Cellar/libunistring/1.1
==> make
==> make check
==> make install
🍺  /usr/local/Cellar/libunistring/1.1: 56 files, 4.9MB, built in 13 minutes 36 seconds
==> Installing wget dependency: gettext
==> Pouring gettext--0.21.1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/gettext/0.21.1: 1,983 files, 20.5MB
==> Installing wget dependency: pkg-config
==> Pouring pkg-config--0.29.2_3.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.2_3: 11 files, 624.0KB
==> Installing wget dependency: libidn2
==> ./configure --prefix=/usr/local/Cellar/libidn2/2.3.4_1 --libdir=/usr/local/Cellar/libidn2/2.3.4_1/lib --with-packager=Homebrew --with-libintl-prefix=/usr/local/opt/gettext
==> make install
🍺  /usr/local/Cellar/libidn2/2.3.4_1: 79 files, 1003.5KB, built in 1 minute 15 seconds
==> Installing wget dependency: ca-certificates
==> Pouring ca-certificates--2023-01-10.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/ca-certificates/2023-01-10: 3 files, 216.9KB
==> Installing wget dependency: openssl@3
==> Pouring openssl@3--3.0.7.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/openssl@3/3.0.7: 6,454 files, 28.4MB
==> Installing wget
==> ./configure --prefix=/usr/local/Cellar/wget/1.21.3_1 --sysconfdir=/usr/local/etc --with-ssl=openssl --with-libssl-prefix=/usr/local/opt/openssl@3 --disable-pcre --disable-pcre2 --without
==> make install
🍺  /usr/local/Cellar/wget/1.21.3_1: 88 files, 4.2MB, built in 2 minutes 46 seconds
==> Running `brew cleanup wget`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/wget/1.21.3... (89 files, 4.2MB)
Removing: /Users/moneyslow.com/Library/Caches/Homebrew/wget--1.21.3... (1.5MB)
Warning: The following dependents of upgraded formulae are outdated but will not
be upgraded because they are not bottled:
  inetutils
  libheif
  glib
  imagemagick
  git
  mysql-client
  libfido2
  tmux
  libssh
  python@3.9
  hydra
==> Upgrading 1 dependent of upgraded formulae:
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
openssl@1.1 1.1.1q -> 1.1.1s
==> Fetching openssl@1.1
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1s
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:210eed5ef3fccfca89ce309648606b1f10a8854a922b8a62ff0dbb23050b46b5
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:210eed5ef3fccfca89ce309648606b1f10a8854a922b8a62ff0dbb23050b46b5?se=2023-01-31T02%3A25%3A00Z&sig=7QxY4s6g
######################################################################## 100.0%
==> Upgrading openssl@1.1
  1.1.1q -> 1.1.1s

==> Pouring openssl@1.1--1.1.1s.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  $(brew --prefix)/etc/openssl@1.1/certs

and run
  $(brew --prefix)/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.1s: 8,101 files, 18.5MB
==> Running `brew cleanup openssl@1.1`...
Removing: /usr/local/Cellar/openssl@1.1/1.1.1q... (8,097 files, 18.5MB)
Removing: /Users/moneyslow.com/Library/Caches/Homebrew/openssl@1.1--1.1.1q... (5.2MB)
==> Checking for dependents of upgraded formulae...
==> No broken dependents found!
==> Caveats
==> openssl@1.1
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  $(brew --prefix)/etc/openssl@1.1/certs

and run
  $(brew --prefix)/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

再次看下wget的版本是否是最新的:

% brew outdated|grep wget

发现已经没有任何输出,已经是最新版本了。

假如你更新了所有的包,最后需要清理旧的安装包,用命令 brew cleanup

Exit mobile version