284 Commits

Author SHA1 Message Date
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
Douglas Eichelberger
d3d25beb35 Use requires_ancestor consistently 2024-10-06 09:25:57 -07:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Bo Anderson
eb93d844d8
Fix NoSuchKegFromTapError handling 2024-09-16 05:46:14 +01:00
Carlo Cabrera
a4b433895c
exceptions: skip #fetch_issues is HOMEBREW_NO_BUILD_ERROR_ISSUES is set
This will allow us to set `HOMEBREW_NO_BUILD_ERROR_ISSUES` in our
workflows, which will avoid needlessly burning through our rate limit.
2024-09-12 14:05:30 +08:00
Rylan Polster
8cb62b1398
Set correct tap when loading installed casks 2024-09-10 13:34:40 -04:00
Bo Anderson
6a0db5035f
Fix misuse of fork in sandbox causing crashes 2024-08-28 13:53:01 +01: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
e3a1a9dccf
Improve locking UX
My experience recently playing around with our locking behaviour is
that, while mostly seamless and not seen by users, it's leaks
implementation details a bit too heavily.

As a result, the following improvements are in this commit:
- Ensure that, whenever possible, we tell the user the actual command
  that is holding a given lock instead of the lock name (an internal
  implementation detail)
- Make the locking error output a little more consistent and user
  friendly
- Add a `DownloadLock` class to simplify locking downloads
- Add a `HOMEBREW_LOCK_CONTEXT` variable to allow adding additional
  context for logging error messages
- Lock paths and leave deciding how this translates to lock names up
  to the locking code itself
- Lock the Cellar/Caskroom paths explicitly rather than implicitly

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-07-30 17:51:02 +01:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Bob
461f49dcb6 fix: Display a warning but continue execution when dumping an exception and unable to find related issues
Occasionally, when failing to `brew install` or `brew upgrade` a formula, users will get an error message and the last line of it will be:
```
Error: Validation Failed: [{"message"=>"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.", "resource"=>"Search", "field"=>"q", "code"=>"invalid"}]
```

Here's an old public example: https://gitlab.com/tabos/rogerrouter/-/issues/21

At Square, this error can be caused by a transient issue with a user's GitHub credentials.

My proposal is that any error which prevents `brew` from showing related issues should:
1. Not cause `brew` to exit early (vs. printing diagnostic checks and doing any other cleanup)
2. Be clearly differentiated from the original failure (so it doesn't become a red herring for users troubleshooting their broken formula)
2024-04-29 11:47:01 -07:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Markus Reiter
5e636174e8
Explicitly mark non-public APIs. 2024-04-23 19:10:45 +02:00
Markus Reiter
4b432c7ea4
Explicitly mark non-private APIs. 2024-04-22 21:16:49 +02:00
Markus Reiter
e0743a1436
Reapply "Refactor Formulary::loader_for."
This reverts commit 24683525cb5abf3cc79a9e0e268fa6efd0af558b.
2024-02-22 18:24:57 +01:00
Mike McQuaid
24683525cb
Revert "Refactor Formulary::loader_for." 2024-02-16 13:41:54 +00:00
Markus Reiter
b717f5d954
Remove unused TapFormulaWithOldnameAmbiguityError. 2024-02-14 22:56:25 +01:00
Markus Reiter
ce60048192
Handle TapFormulaAmbiguityError in diagnostics. 2024-02-14 20:28:08 +01:00
Markus Reiter
4641690674
Refactor Formulary::loader_for. 2024-02-14 20:28:06 +01:00
Eric Knibbe
e63b1f4da5
docs: monospace suggested values 2024-02-04 15:42:26 +01:00
Sam Ford
578c935bcf
Formula, BuildError: Update type signatures
We're seeing type errors when building formulae that use something
like `xcodebuild ..., "-arch", Hardware::CPU.arch`, since `CPU.arch`
is a symbol. We've been addressing these issues by calling `#to_s` on
the value but there was some talk about simply expanding the type
signatures to accommodate anything that will be cast to a `String`.

There's maybe still an argument to be made for doing string conversion
in formulae but expanding the type signatures will resolve a number of
existing type errors if we simply want to rely on implicit type
casting.

Past that, this also updates the type signature for `BuildError` to
align with the `#system` signature changes, as we receive a type error
otherwise.
2023-09-13 19:16:04 -04:00
Eric Knibbe
b3ecd91f97
dev-cmd/edit: suggest tapping core repositories 2023-08-01 13:39:28 -04:00
Colin Dean
de1e1fdf0a
Corrects an uncaught spelling error
I guess someone did mot see it.
2023-07-17 10:33:48 -04:00
Issy Long
b9d8fd4f79
Enable issues_for_formula to show only issues, only PRs, or both
- This change is useful for the "these issues are also open for this
  build failure" exception. Hopefully there'll be less noise on PRs with
  people encouraging us to fix things faster if we don't link them to
  WIP PRs (or any PRs at all).
- Fixes https://github.com/Homebrew/brew/issues/ 15608.
2023-07-08 22:15:58 +01:00
Bo Anderson
68289f1165
Add without_api specifier for CLI named args 2023-06-22 01:57:28 +01:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
eb23a2c44a Enable typing in a couple more files 2023-03-03 08:30:15 -08:00
Douglas Eichelberger
0eccc0e987 git grep -l Utils::Inflection | xargs gsed -i 's|Utils::Inflection|Utils|g' 2023-02-27 20:18:27 -08:00
Douglas Eichelberger
3da68651e5 Port more call sites 2023-02-27 20:18:08 -08:00
EricFromCanada
dfc9906184
internal messaging fixes 2023-02-10 23:17:16 -05:00
Mike McQuaid
46fc4f9f1b
Don't allow HOMEBREW_INSTALL_FROM_API when building from source
When either being in a non-default prefix or being on an unsupported
macOS version we expect most things to be built from source. In that
environment, do not allow HOMEBREW_INSTALL_FROM_API to be set.

Fixes #14475
2023-02-02 14:49:34 +00:00
Sean Molenaar
2de6958a36
build_environment: add proper types to dump() and fix inreplace error 2022-08-15 19:03:55 +02:00
Rylan Polster
e53ccbc3cd
Remove unnecessary code 2022-06-14 16:06:05 -04:00
Bo Anderson
4cb0b1978c
exceptions: fix did_you_mean error in some scenarios 2022-06-02 05:54:42 +01:00
Bo Anderson
d47517f635
exceptions: handle backslash in args for BuildError 2022-05-20 01:41:26 +01:00
Alexander Bayandin
7fb74cb1dc
Fix error message duplication for installation from URL 2021-12-03 13:15:42 +00:00
XuehaiPan
63f2f6cca7 tap: allow to change tap remote with brew tap --custom-remote 2021-10-12 01:11:34 +08:00
Bo Anderson
c49dc6803b
exceptions: set backtrace for FormulaUnreadableError 2021-09-17 00:06:42 +01:00
fn ⌃ ⌥
c0795b5029 upgrade: raise error if developer and there are cyclic dependencies 2021-09-12 07:56:37 -07:00
Michka Popoff
07df4a7e70
Use Homebrew curl for audit and fetch when specified in the formula
Introduce new :using for urls
2021-08-17 13:35:55 +02:00
Kaito Udagawa
fec4ff5ca3
Insert space
I got the following error message:

Install Clang or run `brew install gcc`.Alternatively, remove the flag to attempt bottle installation.

A space is missing after the period. This change ensures a space to be inserted.
2021-08-09 02:21:45 +09:00
Alexander Bayandin
ce4410fd8d
exceptions: add "Did you mean ..." for FormulaOrCaskUnavailableError 2021-06-22 18:06:52 +01:00
Rylan Polster
2760d981d3
Allow for homebrew/core to be untapped 2021-06-17 14:18:43 -04:00
Bo Anderson
728bb547a7
language: raise ShebangDetectionError rather than a generic error 2021-05-10 05:50:08 +01:00
nandahkrishna
585ec90878
cask_loader: do not auto-tap in FromTapLoader 2021-03-11 21:09:42 +05:30