Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoremove detects package that is needed and cannot be removed #13729

Closed
2 tasks done
johan162 opened this issue Aug 21, 2022 · 5 comments
Closed
2 tasks done

autoremove detects package that is needed and cannot be removed #13729

johan162 opened this issue Aug 21, 2022 · 5 comments
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age stale No recent activity

Comments

@johan162
Copy link

brew config output

HOMEBREW_VERSION: 3.5.9-138-gd81bd6a
ORIGIN: https://github.com/Homebrew/brew
HEAD: d81bd6ab3b81397bce36362f81542a5e8bd55b30
Last commit: 13 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 96a8de3ed0da41902c22421d5d37ffa3f7409b49
Core tap last commit: 15 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 16
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 16-core 64-bit kabylake
Clang: 13.1.6 build 1316
Git: 2.32.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.5.1-x86_64
CLT: 13.4.0.0.1.1651278267
Xcode: N/A

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: Homebrew's "sbin" was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting your PATH for example like so:
  echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc

Verification

  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

Trying to clean up no longer used packages with autoremove and then the command tries to remove needed package jpegthat some safety check catches and refuses to remove.

Current installed formulas:

% brew list
==> Formulae
autoconf	freetype	guile		libharu		libtool		ncurses		podman		wget
automake	gawk		htop		libidn		libunistring	nettle		[email protected]	xz
bdw-gc		gdbm		icu4c		libidn2		libusb		node		qemu		yajl
bpytop		gettext		jansson		libiscsi	libuv		openjpeg	readline	zsh
brotli		ghostscript	jbig2dec	libnghttp2	libvirt		[email protected]	snappy		zshdb
c-ares		glib		jpeg		libpng		little-cms2	osx-cpu-temp	sqlite		zstd
ca-certificates	gmp		jpeg-turbo	libslirp	lz4		p11-kit		themeltspice
ctop		gnu-sed		libevent	libssh		lzo		pandoc		tmux
cunit		gnutls		libffi		libssh2		m4		pcre		unbound
doxygen		gotop		libgcrypt	libtasn1	mpdecimal	pixman		utf8proc
fontconfig	grep		libgpg-error	libtiff		mpfr		pkg-config	vde

==> Casks
db-browser-for-sqlite	flycut			mactex			sqlitestudio		vlc
docker			iterm2			multipass		texstudio
doxygen			keka			podman-desktop		tunnelblick
firefox			ltspice			qbittorrent		virtualbox

What happened (include all command output)?

% brew autoremove
==> Autoremoving 1 unneeded formula:
jpeg
Error: Refusing to uninstall /usr/local/Cellar/jpeg/9e
because it is required by openjpeg, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies

openjpeg is brought in by mactexand ghostscript

What did you expect to happen?

That autoremove does not suggest packages that cannot be removed which results in an error. The main problem with this error is that it prevents autoremove from working at all since it seems to require atomic operations (which in other circumstances is probably a good thing).

Even if there are 50 other packages that can safely be removed it is impossible to use autoremove

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

1. `brew autoremove`
@johan162 johan162 added the bug Reproducible Homebrew/brew bug label Aug 21, 2022
@apainintheneck
Copy link
Contributor

It looks like the autoremove logic tags a formula as fit for being removed and then later on another check decides that it isn't. The solution here would be to probably use the same logic in both places or update the autoremove logic to better detect when a package is fit to be removed.

More specifically, the Cleanup#autoremove logic is not accurately detecting that openjpeg is a dependency while Uninstall#check_for_dependents is right before trying to uninstall and that is what is triggering the error message.

I was only able to reproduce the error message when I adding mactex and ghostscript to the HOMEBREW_NO_CLEANUP_FORMULAE environment variable. Do you have that set right now?

export HOMEBREW_NO_CLEANUP_FORMULAE=mactex,ghostscript

In that case, there seems to be an error with ignoring those no cleanup formulae during the autoremove process.

@carlocab
Copy link
Member

I was only able to reproduce the error message when I adding mactex and ghostscript to the HOMEBREW_NO_CLEANUP_FORMULAE environment variable. Do you have that set right now?

export HOMEBREW_NO_CLEANUP_FORMULAE=mactex,ghostscript

I think what actually is happening here is that mactex (or perhaps something else installed) used to depend on jpeg (note: not openjpeg) via ghostscript, and this fact is recorded somewhere that isn't updated when ghostscript was rebuilt to depend on jpeg-turbo instead.

If this is correct, then this is related to #13717.

@carlocab
Copy link
Member

Actually, openjpeg used to depend on jpeg via libtiff and little-cms2.

I suspect openjpeg has not be reinstalled or upgraded since the switch to jpeg-turbo was made, which means the jpeg dependency is still recorded in openjpeg's tab.

@carlocab
Copy link
Member

carlocab commented Aug 21, 2022

What's the output of

brew ruby -e 'puts Tab.for_formula(:openjpeg.f).runtime_dependencies'

?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Sep 12, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2022
@github-actions github-actions bot added the outdated PR was locked due to age label Oct 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age stale No recent activity
Projects
None yet
Development

No branches or pull requests

3 participants