Fixes#20374
When using HOMEBREW_DOWNLOAD_CONCURRENCY, cask binaries were being
downloaded before checking if the cask could actually be installed
(e.g., disabled casks or conflict checks). This resulted in unnecessary
downloads for casks that would ultimately fail to install.
This change adds a `prelude` method to Cask::Installer that performs
early validation checks (deprecation/disable status and conflicts)
similar to Formula#prelude_fetch. The prelude method is called before
enqueueing downloads in all download queue scenarios (install, reinstall,
and upgrade commands), ensuring that validation failures occur before
the "Fetching downloads for:" message is displayed.
Key changes:
- Add Cask::Installer#prelude method with @ran_prelude tracking
- Call prelude before enqueueing downloads in install/reinstall/upgrade
- Refactor to avoid creating installer objects multiple times
- Maintain backward compatibility for non-download-queue scenarios
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Change styling based on output of brew typecheck and brew style
Changes as per PR comments
Remove --leaves flag functionality
Simplify formulae and cask parsing as well as style changes as per PR comments
Update cask and formulae parsing as per PR comment suggestion
Add column formatting function as well as PR comment suggestions
Add Sorbet struct for printing and minor logic changes as per PR comments
Minor changes as per PR comments and fix formatting issue in output
Update the naming, presence and values for various download queue
methods to improve the output for users while making the internal code
a little easier to follow.
While we're here, also ensure that a single formula download still
displays the download queue output and indirectly fix an issue with
bottle manifests being named incorrectly.
The `Cask::Cask` objects in the `SkipConditions` tests don't
interpolate `version` in the `url` strings, so these are technically
unversioned URLs as a result and would be skipped as unversioned. This
updates the URLs accordingly, so they won't trigger the unversioned
skip as a fallback (if the intended test doesn't work as expected).
This is something I discovered while writing a test for a cask that
shouldn't be skipped.
We've been adding `disable!` calls with a future date to casks using
an unsigned app. That implicitly deprecates the cask until it reaches
the disable date, so we've been having to add simple `livecheck`
blocks to casks that use a default check to ensure that livecheck
continues to check them. It was suggested that it would be simpler to
have livecheck not skip casks that have a `disable!` call with a
`because: :unsigned` argument and I agree, so this modifies
`SkipConditions` to add a special case for this scenario.
`ensure_formula_installed!` requires the `Formula` class to be loaded
before being called to work properly.
Let's guarantee that instead by implementing it as an instance method of
the `Formula` class.
See discussion at #20358.
This does the same as #20356 for `ensure_formula_installed!`. See
discussion at #20352.
Unfortunately, one must still `require "formula"` before using this
method because of the `returns(Formula)`, but tightening the type
signature is generally a good idea anyway.
Closes#20352.
Allowing either `Formula`e or `String`s in these methods leads to errors
at runtime when one hasn't done `require "formula"` yet.
Let's tighten these up so that they only accept `Formula` arguments to
guarantee that `require "formula"` has been done before they are called.
For callers that need to pass a `String`, we update them to call a
version of these methods that accepts only `String`s.
See discussion at #20352.
Fixes
❯ HOMEBREW_BAT=1 brew cat xz
Error: uninitialized constant Kernel::Formula
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/extend/kernel.rb:445:in 'block in <module:Kernel>'
/opt/homebrew/Library/Homebrew/dev-cmd/cat.rb:33:in 'block in Homebrew::DevCmd::Cat#run'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/lib/ruby/3.4.0/fileutils.rb:241:in 'Dir.chdir'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/lib/ruby/3.4.0/fileutils.rb:241:in 'FileUtils#cd'
/opt/homebrew/Library/Homebrew/dev-cmd/cat.rb:29:in 'Homebrew::DevCmd::Cat#run'
/opt/homebrew/Library/Homebrew/brew.rb:113:in '<main>'
Please report this issue:
https://docs.brew.sh/Troubleshooting
These were being downloaded twice simultaneously which causes a locking
race condition.
While we're here, also improve the output of bottle manifests and
patches in the download queue.
The error message to be fixed:
```console
% brew audit --strict --online xz
xz
* Stable: The source URL http://downloads.sourceforge.net/project/lzmautils/xz-5.8.1.tar.gz should use HTTPS rather than HTTP
Error: 1 problem in 1 formula detected.
% brew edit xz # change it to https
% brew audit --strict --online xz
xz
* Stable: should always include at least one HTTP mirror
Error: 1 problem in 1 formula detected.
```
- Fixes https://github.com/Homebrew/brew/issues/15728
This must set `disable` to `true` to have correct behaviour.
Also, don't allow setting it to `false` to avoid confusion as
that's what `odeprecated` is for.
`cmd` can be a `Pathname` (see the type signature), but `ohai` seems to
expect only `String`s now.
While we're here, let's assert that `cmd` exists whenever it is a
`Pathname`, to avoid passing arguments like `bin/"cmd --version"` (which
is not a valid `Pathname`).
See, for example, Homebrew/homebrew-core#231882.