-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
cmd/untap: fix untapping syntax failure. #16330
Conversation
If an installed cask is invalid on attempting an untap: it will prevent untapping that cask. Fix this in two ways: one more specific to `untap` and one more generally to other commands too: - specific: only read the actual formulae/casks from the tap we're untapping instead of all of those that are installed - general: rescue more exceptions in `Cask::Caskroom.casks` (like we already do for `Formula.installed`
Looks generally good but one concern I have is shadowed names. It's very much possible for two taps to have the same package name but we are no longer checking here which tap we have actually installed from. That information is probably not available for casks, but it is for formulae (in the tab). |
@Bo98 Sorry, didn't see this before auto-merge kicked in. Looking again at the implementation: I think this is handled/should be fine the name shadowing will only result in e.g. If there's a missing case here (particularly if overly liberal rather than conservative): will happily open a follow-up PR! |
Oh right, yeah I think I misread it sorry! There's two installed checks yeah - the initial list and then the second real-formula check. All looks good! |
Or actually, I think brew/Library/Homebrew/formula.rb Lines 617 to 619 in bd378a7
I'm cautious about changing |
It doesn't but: the formula load has already explicitly loaded from the tap. |
To demonstrate what I mean: $ brew ruby -rformula -e 'puts Formula["homebrew/core/openssl@3"].any_version_installed?'
true
$ cat >$(brew --repo bo98/experimental)/Formula/[email protected] <<EOS
class OpensslAT3 < Formula
url "abc"
version "3"
end
EOS
$ brew ruby -rformula -e 'puts Formula["bo98/experimental/openssl@3"].any_version_installed?'
true
$ jq '.source.tap' $(brew --prefix openssl@3)/INSTALL_RECEIPT.json
"homebrew/core" Instead of $ brew ruby -rformula -e 'f = Formula["homebrew/core/openssl@3"]; puts f.installed_kegs.any? { |keg| keg.tab.tap == f.tap }'
true
$ brew ruby -rformula -e 'f = Formula["bo98/experimental/openssl@3"]; puts f.installed_kegs.any? { |keg| keg.tab.tap == f.tap }'
false |
@Bo98 Thanks, that helps. Can you reproduce a similar issue/fix with casks? It looks like they don't store taps in their metadata at all. |
The same issue likely applies to casks, but unfortunately the information is not there to sufficiently fix it if installed from Ruby (JSON seems to have more info). We should start storing tap metadata for Ruby installs - this is not the first time I've noticed tap information has been lacking there. Casks in third-party taps has been somewhat lacking and undertested in general. I've noticed several things hardcoded to |
If an installed cask is invalid on attempting an untap: it will prevent untapping that cask.
Fix this in two ways: one more specific to
untap
and one more generally to other commands too:Cask::Caskroom.casks
(like we already do forFormula.installed
Fixes #16321