Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
40.88k stars 9.59k forks source link

Cleanup runs automatically after just one package is upgraded #5627

Closed bdesham closed 5 years ago

bdesham commented 5 years ago

Please note that we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

What you were trying to do (and why)

I ran brew upgrade to upgrade my packages.

What happened (include command output)

brew cleanup is run automatically now (see #4760). In this case, it was run after the very first package was installed, despite the fact that there were 18 more packages that still needed to be upgraded. The cleanup command itself issued a ton of warnings like

Warning: Skipping glib: most recent version 2.58.3 not installed

Due to an unrelated problem with one of my packages the brew cleanup command aborted and I was left with just one package having been upgraded. I tried running brew upgrade again and this time it installed a different package but still ran brew cleanup, with the same result as before.

I searched the issue tracker, found issue #4760 and the environment variable mentioned there, and tried running

HOMEBREW_NO_INSTALL_CLEANUP=1 brew upgrade

This allowed the upgrade to complete successfully.

Output from two runs of brew cleanup
9004 ~ $ brew update
Updated Homebrew from dac15adbe to ede58e8dc.
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
angular-cli               gdal                      libxml2                   nwchem
epubcheck                 libbi                     node                      spice-protocol
==> Deleted Formulae
ruby@1.8
9005 ~ $ brew upgrade
==> Upgrading 19 outdated packages:
coreutils 8.30 -> 8.30_1, ffmpeg 4.1_1 -> 4.1_2, python@2 2.7.15_1 -> 2.7.15_2, pango 1.42.4 -> 1.42.4_1, glib 2.58.2 -> 2.58.3, readline 7.0.5 -> 8.0.0, webp 1.0.1 -> 1.0.2, sqlite 3.26.0 -> 3.26.0_1, libgpg-error 1.33 -> 1.34, gawk 4.2.1 -> 4.2.1_1, librsvg 2.44.11 -> 2.44.12, mplayer 1.3.0 -> 1.3.0_1, youtube-dl 2019.01.17 -> 2019.01.24, x265 2.9 -> 3.0, zsh 5.6.2_1 -> 5.7, imagemagick 7.0.8-23_1 -> 7.0.8-24, p11-kit 0.23.14 -> 0.23.15, ruby 2.6.0 -> 2.6.0_1, libvterm 681 -> 726
==> Upgrading readline 
==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.0.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-8.0.0.high_sierra.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

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

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

==> Summary
🍺  /usr/local/Cellar/readline/8.0.0: 48 files, 1.5MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/bdesham/Library/Caches/Homebrew/automake--1.16.1_1.high_sierra.bottle.tar.gz... (943.3KB)
Removing: /usr/local/Cellar/boost/1.68.0... (13,712 files, 460.2MB)
Warning: Skipping coreutils: most recent version 8.30_1 not installed
Warning: Skipping ffmpeg: most recent version 4.1_2 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/fontconfig--2.13.1.high_sierra.bottle.tar.gz... (1.2MB)
Warning: Skipping gawk: most recent version 4.2.1_1 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/gdbm--1.18.1.high_sierra.bottle.tar.gz... (192.4KB)
Removing: /Users/bdesham/Library/Caches/Homebrew/gitup--git... (46 files, 70.6KB)
Warning: Skipping glib: most recent version 2.58.3 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/glib--2.58.2.high_sierra.bottle.tar.gz... (5.6MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/gnu-sed--4.7.high_sierra.bottle.tar.gz... (201.5KB)
Warning: Skipping imagemagick: most recent version 7.0.8-24 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/imagemagick--7.0.8-23.high_sierra.bottle.tar.gz... (8.4MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/imagemagick--7.0.8-21.high_sierra.bottle.tar.gz... (8.5MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/imagemagick--7.0.8-23_1.high_sierra.bottle.tar.gz... (8.6MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/jsonpp--1.3.0_1.high_sierra.bottle.tar.gz... (843.2KB)
Warning: Skipping libgpg-error: most recent version 1.34 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/libgpg-error--1.33.high_sierra.bottle.tar.gz... (276.1KB)
Removing: /usr/local/Cellar/libidn2/2.0.5... (68 files, 668.8KB)
Removing: /Users/bdesham/Library/Caches/Homebrew/libmagic--5.35.high_sierra.bottle.tar.gz... (749.7KB)
Warning: Skipping librsvg: most recent version 2.44.12 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/librsvg--2.44.10.high_sierra.bottle.tar.gz... (23.9MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/librsvg--2.44.11.high_sierra.bottle.tar.gz... (23.9MB)
Warning: Skipping libvterm: most recent version 726 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/links--2.17.high_sierra.bottle.tar.gz... (693.6KB)
Removing: /usr/local/Cellar/mkvtoolnix/29.0.0_1... (37 files, 19.6MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/mkvtoolnix--29.0.0_1.high_sierra.bottle.1.tar.gz... (6.4MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/mosh--1.3.2_4.high_sierra.bottle.tar.gz... (323.7KB)
Warning: Skipping mplayer: most recent version 1.3.0_1 not installed
Removing: /usr/local/Cellar/nvm/0.33.11... (7 files, 138.6KB)
Removing: /Users/bdesham/Library/Caches/Homebrew/opus--1.3.high_sierra.bottle.tar.gz... (444KB)
Warning: Skipping p11-kit: most recent version 0.23.15 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/p11-kit--0.23.14.high_sierra.bottle.tar.gz... (693.7KB)
Warning: Skipping pango: most recent version 1.42.4_1 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/pcre2--10.32.high_sierra.bottle.tar.gz... (1.8MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/perl--5.28.1.high_sierra.bottle.tar.gz... (16.2MB)
Warning: Skipping (old) /usr/local/Cellar/python/3.7.0 due to it being linked
Warning: Skipping python@2: most recent version 2.7.15_2 not installed
Removing: /usr/local/Cellar/readline/7.0.5... (46 files, 1.5MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/ripgrep--0.10.0.high_sierra.bottle.tar.gz... (2MB)
Warning: Skipping ruby: most recent version 2.6.0_1 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/ruby--2.6.0.high_sierra.bottle.tar.gz... (9.1MB)
Warning: Skipping sqlite: most recent version 3.26.0_1 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/sqlite--3.26.0.high_sierra.bottle.tar.gz... (1.8MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/tesseract--4.0.0.high_sierra.bottle.1.tar.gz... (8.9MB)
Warning: Skipping webp: most recent version 1.0.2 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/webp--1.0.1.sierra.bottle.tar.gz... (838.9KB)
Removing: /usr/local/Cellar/wget/1.20.1... (50 files, 3.9MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/wget--1.20.1.high_sierra.bottle.1.tar.gz... (1.4MB)
Warning: Skipping x265: most recent version 3.0 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/x265--2.9.high_sierra.bottle.tar.gz... (4.8MB)
Warning: Skipping youtube-dl: most recent version 2019.01.24 not installed
Removing: /Users/bdesham/Library/Caches/Homebrew/youtube-dl--2019.01.17.tar.gz... (2.9MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/youtube-dl--2018.12.17.tar.gz... (2.9MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/youtube-dl--2019.01.10.tar.gz... (2.9MB)
Removing: /Users/bdesham/Library/Caches/Homebrew/youtube-dl--2019.01.02.tar.gz... (2.9MB)
Warning: Skipping zsh: most recent version 5.7 not installed
Removing: /Users/bdesham/Library/Logs/Homebrew/lynx... (64B)
Error: Permission denied @ unlink_internal - /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuPro-W3
9006 ~ $ brew upgrade
==> Upgrading 18 outdated packages:
coreutils 8.30 -> 8.30_1, ffmpeg 4.1_1 -> 4.1_2, python@2 2.7.15_1 -> 2.7.15_2, pango 1.42.4 -> 1.42.4_1, glib 2.58.2 -> 2.58.3, webp 1.0.1 -> 1.0.2, sqlite 3.26.0 -> 3.26.0_1, libgpg-error 1.33 -> 1.34, gawk 4.2.1 -> 4.2.1_1, librsvg 2.44.11 -> 2.44.12, mplayer 1.3.0 -> 1.3.0_1, youtube-dl 2019.01.17 -> 2019.01.24, x265 2.9 -> 3.0, zsh 5.6.2_1 -> 5.7, imagemagick 7.0.8-23_1 -> 7.0.8-24, p11-kit 0.23.14 -> 0.23.15, ruby 2.6.0 -> 2.6.0_1, libvterm 681 -> 726
==> Upgrading ruby 
==> Downloading https://homebrew.bintray.com/bottles/ruby-2.6.0_1.high_sierra.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring ruby-2.6.0_1.high_sierra.bottle.1.tar.gz
==> Caveats
By default, binaries installed by gem will be placed into:
  /usr/local/lib/ruby/gems/2.6.0/bin

You may want to add this to your PATH.

ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

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

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

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

==> Summary
🍺  /usr/local/Cellar/ruby/2.6.0_1: 19,334 files, 32.3MB
==> `brew cleanup` has not been run in 30 days, running now...
Warning: Skipping coreutils: most recent version 8.30_1 not installed
Warning: Skipping ffmpeg: most recent version 4.1_2 not installed
Warning: Skipping gawk: most recent version 4.2.1_1 not installed
Warning: Skipping glib: most recent version 2.58.3 not installed
Warning: Skipping imagemagick: most recent version 7.0.8-24 not installed
Warning: Skipping libgpg-error: most recent version 1.34 not installed
Warning: Skipping librsvg: most recent version 2.44.12 not installed
Warning: Skipping libvterm: most recent version 726 not installed
Warning: Skipping mplayer: most recent version 1.3.0_1 not installed
Warning: Skipping p11-kit: most recent version 0.23.15 not installed
Warning: Skipping pango: most recent version 1.42.4_1 not installed
Warning: Skipping (old) /usr/local/Cellar/python/3.7.0 due to it being linked
Warning: Skipping python@2: most recent version 2.7.15_2 not installed
Removing: /usr/local/Cellar/ruby/2.6.0... (19,334 files, 32.3MB)
Warning: Skipping sqlite: most recent version 3.26.0_1 not installed
Warning: Skipping webp: most recent version 1.0.2 not installed
Warning: Skipping x265: most recent version 3.0 not installed
Warning: Skipping youtube-dl: most recent version 2019.01.24 not installed
Warning: Skipping zsh: most recent version 5.7 not installed
Error: Permission denied @ unlink_internal - /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuPro-W3  
  

What you expected to happen

I didn’t really expect brew cleanup to run by itself, but I suppose that’s a separate issue. The problem here is that brew cleanup ran after the first installation of brew upgrade rather than waiting for that command to install everything it needed to.

I understand why brew cleanup is being run automatically now, but I also think that if this command fails for any reason, Homebrew should probably not attempt to run it again automatically until it has been successful again.

Step-by-step reproduction instructions (by running brew commands)

  1. Have multiple packages that need to be updated
  2. Make sure you haven’t run brew cleanup in the past 30 days
  3. Run brew upgrade

Other information

brew config output
HOMEBREW_VERSION: 1.9.3-34-gede58e8
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: ede58e8dc7079cabd71dde83cd7ae57881034146
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 4851f31df8a4f5ce3e4b254646a9f9e82dab25e7
Core tap last commit: 6 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_LOGS: /Users/bdesham/Library/Logs/Homebrew
HOMEBREW_VISUAL: mvim
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.20.1 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_66
macOS: 10.13.6-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: 10.1
XQuartz: 2.7.11 => /opt/X11
  
brew doctor output
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Putting non-prefixed coreutils in your path can cause gmp builds to fail.

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libtcl8.6.dylib
  /usr/local/lib/libtk8.6.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/fakemysql.h
  /usr/local/include/fakepq.h
  /usr/local/include/fakesql.h
  /usr/local/include/itcl.h
  /usr/local/include/itcl2TclOO.h
  /usr/local/include/itclDecls.h
  /usr/local/include/itclInt.h
  /usr/local/include/itclIntDecls.h
  /usr/local/include/itclMigrate2TclCore.h
  /usr/local/include/itclTclIntStubsFcn.h
  /usr/local/include/mysqlStubs.h
  /usr/local/include/odbcStubs.h
  /usr/local/include/pqStubs.h
  /usr/local/include/tcl.h
  /usr/local/include/tclDecls.h
  /usr/local/include/tclOO.h
  /usr/local/include/tclOODecls.h
  /usr/local/include/tclPlatDecls.h
  /usr/local/include/tclThread.h
  /usr/local/include/tclTomMath.h
  /usr/local/include/tclTomMathDecls.h
  /usr/local/include/tdbc.h
  /usr/local/include/tdbcDecls.h
  /usr/local/include/tdbcInt.h
  /usr/local/include/tk.h
  /usr/local/include/tkDecls.h
  /usr/local/include/tkPlatDecls.h

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
  /usr/local/lib/pkgconfig/tcl.pc
  /usr/local/lib/pkgconfig/tk.pc

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libtclstub8.6.a
  /usr/local/lib/libtkstub8.6.a

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  ghc@8.0

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuPro-W3
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuPro-W6
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuProN-W3
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuProN-W6
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuStd-W8
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuStdN-W8
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraMaruPro-W4
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraMaruProN-W4
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraMinPro-W3
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraMinPro-W6
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraMinProN-W3
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraMinProN-W6
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraginoSansGB-W3
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraginoSansGB-W6
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/YuGo-Bold
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/YuGo-Medium
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/YuMin-Demibold
  /usr/local/share/ghostscript/9.16/Resource/CIDFont/YuMin-Medium
  
MikeMcQuaid commented 5 years ago

Error: Permission denied @ unlink_internal - /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuPro-W3

This would also most likely cause brew upgrade to fail if ghostscript were upgraded, FYI.

The problem here is that brew cleanup ran after the first installation of brew upgrade rather than waiting for that command to install everything it needed to.

This is intentional and although the reasoning may appear weird the first time because it's usually doing a per-package cleanup in this situation.

I understand why brew cleanup is being run automatically now, but I also think that if this command fails for any reason, Homebrew should probably not attempt to run it again automatically until it has been successful again.

I don't agree as this would block brew cleanup from every being run again in your situation which is not desirable (without the environment variable declaring it so).

While this seems to be an issue with your permissions/configuration on your personal machine brew cleanup could perhaps better handle permission errors it encounters.