195 Commits

Author SHA1 Message Date
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.

While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
2025-08-20 19:20:19 +01:00
Eric Knibbe
827480f06b
messages/comments: wording fixes 2025-08-16 00:57:59 -04:00
Mike McQuaid
ec56bbf289
Improve extend/* Sorbet typing 2025-07-31 17:31:27 +01:00
copilot-swe-agent[bot]
ebb71682ab
Improve error message for tap conflicts in brew install
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
Co-authored-by: carlocab <30379873+carlocab@users.noreply.github.com>
2025-07-25 09:39:19 +01:00
Mike McQuaid
e10d4c43c2
Optionally use DownloadQueue for reinstall, upgrade.
Follow up on `DownloadQueue` for download concurrency on `brew fetch`
and `brew install` to also add support for `brew reinstall` and
`brew upgrade`.

This required a fair bit of refactoring to make this work so I've also
made `install.rb`, `reinstall.rb` and `upgrade.rb` `typed: strict` to
add some extra guardrails from Sorbet here.

Co-authored-by: Carlo Cabrera <github@carlo.cab>
2025-07-24 15:41:03 +01:00
Bo Anderson
b2ffe7b060
Fix handling of formula install blocks 2025-07-23 21:19:22 +01:00
Mike McQuaid
5cc6722372
Optionally use DownloadQueue for brew install
Allowing using `HOMEBREW_DOWNLOAD_CONCURRENCY` to use the
`DownloadQueue` for `brew install` by downloading and extracting
bottles in parallel.

This requires some fixes in e.g. `Dependency` and `FormulaInstaller`
to be able to front-load all downloads and handle parallelisation of
bottle pouring.

Behaviour without `HOMEBREW_DOWNLOAD_CONCURRENCY` set should be
unchanged.

Attestations are not handled for now and the UI should be improved
before we roll this out to users.

Post-install upgrades are not yet parallelised.

Co-authored-by: Carlo Cabrera <github@carlo.cab>
2025-07-18 15:00:23 +01:00
Patrick Linnane
4513a43d53
Fix RuboCop failures.
Co-authored-by: Patrick Linnane <patrick@linnane.io>
Co-authored-by: Carlo Cabrera <github@carlo.cab>
Co-authored-by: Thierry Moisan <thierry.moisan@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-07-14 19:12:38 +01:00
Carlo Cabrera
57024a9f2d
Merge pull request #20195 from tyuwags/ask-option-refactoring
Ask option refactoring
2025-07-03 12:28:46 +00:00
Issy Long
c7af63488d
Be more explicit that we want the formula name 2025-07-03 11:29:50 +01:00
Issy Long
5310c5e730
Fix "undefined method 'name' for an instance of FormulaInstaller"
- Because `name` is not a method on `FormulaInstaller`, instead
  `formula` shows the name.
- Fixes issue 20199.

Before:

```
$ brew install -n hello
Error: undefined method 'name' for an instance of FormulaInstaller
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/install.rb:330:in 'Array#map'
/opt/homebrew/Library/Homebrew/install.rb:330:in 'Homebrew::Install.install_formulae'
```

After:

```
$ brew install -n hello
==> Would install 1 formula:
hello
```
2025-07-01 22:25:22 +01:00
thibhero
c7f7ab5631 duplicate in ask_formulae 2025-06-29 23:29:18 -04:00
thibhero
e731b572f3 correcting rescue to use installer and not formula 2025-06-27 03:50:26 -04:00
thibhero
9e131d0794 correcting error of installation dependency
resolves #20181
2025-06-26 19:12:39 -04:00
Thibaut Hérault
bcc7f0f796
Update Library/Homebrew/install.rb
Co-authored-by: Bo Anderson <mail@boanderson.me>
2025-06-20 11:10:18 -04:00
thibhero
19901b5332 refactoring style to resolve the last discussions 2025-06-18 16:05:19 -04:00
Thibaut Hérault
27a040cc32
Merge branch 'master' into master 2025-06-17 20:49:18 -04:00
Mike McQuaid
9ac306e464
Remove alias generic_* definitions in favour of using super
This is the pattern we've been adopting for a while and it's a bit
cleaner. Let's remove all of the existing usage of the existing pattern
to avoid confusion when adopting the new one.
2025-06-16 08:10:08 +00:00
thibhero
7e876e4681 resolving discussions 2025-06-11 22:35:00 -04:00
thibhero
aa47105d2a refactoring code 2025-06-09 00:14:16 -04:00
thibhero
a5251b2fb6 refactoring install 2025-06-08 12:34:24 -04:00
thibhero
fd159ed32c updating ask function 2025-06-08 11:32:21 -04:00
thibhero
3f1341eb6a modifying ask function as it didn't find the whole hierarchy for parents 2025-05-31 12:53:38 -04:00
thibhero
76e7a13332 applying brew tests, typecheck, style 2025-05-07 12:29:32 -04:00
thibhero
f875dbc8a7 Implementing ask input with casks
renamed `ask` to `ask_formulae`
moving option `--ask` to work with formulae and casks
2025-05-07 12:07:29 -04:00
thibhero
5013c17474 formatting correctly with brew style 2025-05-03 15:39:43 -04:00
thibhero
1416da262b returning if formulae is empty 2025-05-03 15:23:20 -04:00
Mike McQuaid
d899f00c4b
Link to Support Tiers in diagnostic/error messages
Now that we have this nice URL let's reference it to allow our other
messages to be a bit shorter/kinder.
2025-04-01 11:35:27 +01:00
Mike McQuaid
e41a1f6d8a
Add brew install --as-dependency
This option avoids needing to immediately use
`brew tab --no-installed-on-request` when manually installing a
dependency.
2025-03-21 15:49:22 +00:00
Osama Albahrani
fde3538900
install.rb: add "no" in --ask output
- improves https://github.com/Homebrew/brew/pull/19254
2025-03-12 00:31:13 +03:00
thibhero
96983ee4ef Specifying the plural of formula 2025-03-07 16:21:05 -05:00
thibhero
c1d80ecf54 resolving conversations from pull request 2025-03-07 16:18:17 -05:00
thibhero
d7723fa6ed resolving conversations from pull request 2025-03-07 11:32:34 -05:00
thibhero
640556df39 correcting big space while displaying 2025-03-06 23:52:12 -05:00
thibhero
0b302dc3ad always include 2025-03-06 22:32:51 -05:00
thibhero
8506f1901a check only if formula is bottled for first formula 2025-03-06 22:20:52 -05:00
thibhero
483aa26aaa checking also the formula itself 2025-03-06 22:02:45 -05:00
thibhero
99fad7797c modifying files with brew style 2025-03-06 21:27:13 -05:00
thibhero
0b53e54bfa Moving ask input to Install.ask 2025-03-05 17:38:18 -05:00
thibhero
c5d80271f4 dont ask input if gets doesnt exist because of test 2025-03-02 20:03:39 -05:00
thibhero
7b3e469650 wrong array of formulae in compute sized 2025-02-25 14:28:44 -05:00
thibhero
1a43a9d258 extracting method to Homebrew/install.rb 2025-02-18 22:41:40 -05:00
Mike McQuaid
b49625a7dc
Add brew install --skip-link
We already have `--skip-post-install` and this adds similar behaviour
for e.g. `brew bundle` (and other users) to be able to install a
formula but skip the `brew link` stage afterwards.
2025-01-23 14:42:03 +00:00
Mike McQuaid
4d4531c19d
Revamp installed_on_request handling
- `reinstall` and `upgrade` no longer mark as installed on request,
  with or without names specified, but preserve the version from the
  tab instead
- default `install_on_request` to `false` rather than `true`
- only set installed in request in a tab if it's missing rather than
  false

Co-authored-by: Michael Cho <michael@michaelcho.dev>
2024-11-19 08:39:55 +00:00
Mike McQuaid
d1e539cb84
Merge pull request #18547 from Homebrew/cask-formula-dep-preinstall
Perform preinstall checks when a formula is installed via a cask
2024-10-13 17:40:59 +01:00
Bob Lail
a5db113d91 feat: Install an unlinked formula via brew install if --overwrite is passed
If the intention is to overwrite any existing links, then `brew install` should go on to install over an unlinked formula
2024-10-12 11:50:51 -07:00
Bo Anderson
97866f8adf
Perform preinstall checks when a formula is installed via a cask 2024-10-11 16:57:47 +01:00
Douglas Eichelberger
2d16333bbc Replace removable constants with overridable methods 2024-10-07 18:33:03 -07:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
af40f7d133
Revert "Create '.keepme' files in directories" 2024-05-10 08:26:31 +01:00