361 Commits

Author SHA1 Message Date
Ruoyu Zhong
454fc6e745
diagnostic: fix undefined ohai method
Fixes #20555.
2025-08-23 20:52:31 +08:00
Branch Vincent
c142a75eea
diagnostic: fix missing string interpolation 2025-08-22 19:39:31 -07:00
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
Bo Anderson
1ae7394b2c
diagnostic: fix error on verbose 2025-08-19 17:29:44 +01:00
Ruoyu Zhong
1eb070e257
diagnostic: don't expand tildes in cask env vars
We double quote them so they don't get expanded. Also, use `sh_quote` to
quote the variable values properly.
2025-08-19 16:42:06 +08:00
Ruoyu Zhong
31598ca8ef
diagnostic: improve tilde expansion logic
This is a bit pedantic, but the tilde expansion only occurs if the tilde
is at the beginning of the string (if we only take the current user into
account) [1].

[1]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_06_01
2025-08-19 16:42:06 +08:00
Ruoyu Zhong
b749cbcffd
diagnostic: fix cask env var output
With `each`, we don't actually output the processed values. We should
therefore be using `filter_map` instead.
2025-08-19 16:42:06 +08:00
Mike McQuaid
6db1f6a052
**/diagnostic.rb: add Sorbet strict sigil.
Making more files `typed: strict` slowly but surely.
2025-08-19 09:10:24 +01:00
Ruoyu Zhong
10ec91cdeb
diagnostic: fix check_cask_environment_variables check
Fixes #20505.
2025-08-19 15:22:58 +08:00
Douglas Eichelberger
bdc219a39a
Move 'paths' out of Kernel 2025-08-16 16:38:27 -07:00
Patrick Linnane
2605529a90
brew style --fix 2025-08-13 12:23:12 -07:00
copilot-swe-agent[bot]
4ee43fbde1
Improve quarantine support error messages with specific CLT guidance
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
2025-08-13 14:30:05 +01:00
Colin Dean
f08122937f
Reorders git options for uncommitted modifications nudge
-C path must come before the subcommand.

Co-authored-by: Carlo Cabrera <github@carlo.cab>
2025-08-05 14:58:44 -04:00
Colin Dean
60ce25bea0
Use git's -C option to set git's working directory for uncommitted modifications nudge 2025-08-05 14:49:11 -04:00
Colin Dean
7d285c0956
diagnostic: Use pushd/popd in uncommited modifications nudge
While filing https://github.com/Homebrew/brew/issues/20379, I lost where I was because I followed the given instruction. Instead, let's use pushd/popd so the user is returned to their pwd if the git operations succeed.
2025-08-05 11:48:39 -04:00
Douglas Eichelberger
40c58a883d
Enable strict typing in Tap 2025-08-04 13:11:15 -07:00
Eric Knibbe
6255263b51
output: express environment variables consistently 2025-08-04 09:50:06 -04: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
Mike McQuaid
7019df7481
Provide more leeway to file Tier 2/3 issues.
Let's still continue to tell people to not file some issues but allow
them to file others.

While we're here, let's me a bit more chill with the language here.
2025-06-27 15:27:26 +01:00
Rylan Polster
426da94cc9
Remove redundant xattr doctor check on systems without quarantine support 2025-06-24 03:07:04 +00:00
Rylan Polster
2acd4e4293
Improve messaging with missing xattr 2025-06-22 18:59:52 +00:00
Rylan Polster
12e5e24ce3
Improve brew doctor warnings about xattr and cask quarantine 2025-06-22 14:24:22 -04:00
Rylan Polster
e1873d30d4
Run deprecated cask tap check on all systems 2025-06-21 13:59:58 -04:00
Rylan Polster
031160936f
Split out os-specific cask software version checks 2025-06-21 13:59:57 -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
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
Adrian Ho
af49990b4f diagnostic: allow macFUSE FUSE3 files
FUSE 3 support was introduced in macFUSE 4.10.0.

Resolves #19650.
2025-03-30 21:41:16 +08:00
Mike McQuaid
bdeca530ff
Migrate Homebrew/bundle to Homebrew/brew
Co-authored-by: Bo Anderson <mail@boanderson.me>
2025-03-19 06:47:01 +00:00
Adrian Ho
86ec9c7c93 diagnostic: enforce user_path_1 prerequisite
Resolves #19447.
2025-03-10 10:14:47 +08:00
Mike McQuaid
7a5d4256e5
Fix Rubocop warnings (without brew style --fix) 2025-02-28 09:59:32 +00:00
Adrian Ho
571da49165 diagnostic: fix call to missing_dependencies
Followup to #19323.
2025-02-25 19:12:11 +08:00
Douglas Eichelberger
a81239ec2d
Enable strict typing in Formula 2025-02-24 10:23:42 -08:00
Adrian Ho
ce60f412e6 diagnostic: recommend untap where possible
Addresses #19334.
2025-02-21 00:27:59 +08:00
Mike McQuaid
7d41a93c76
diagnostic: skip duplicate formulae and casks check inside test-bot.
This makes the experience nicer for tap maintainers who may want to do
this but without hiding the actual warnings for users.
2025-02-19 08:38:31 +00:00
Adrian Ho
46b49ff34d diagnostics: add formula/cask dup check
Duplicate names across taps are a real pain to deal with, so let's warn the user.
2025-02-18 22:38:40 +08:00
Adrian Ho
872bb92639 Update Library/Homebrew/diagnostic.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-01-19 23:19:03 +08:00
Adrian Ho
2d02c3950f diagnostic: elide stray filenames in subdirs
Usually, the subdirectory name is sufficient info, and the full file list is just noise.

This reduces `brew doctor` output clutter, making it easier for user to paste, and maintainers to parse.

Before:
```
$ brew doctor
[...]
Unexpected header files:
  /usr/local/include/node/cppgc/allocation.h
  /usr/local/include/node/cppgc/common.h
  /usr/local/include/node/cppgc/custom-space.h
  /usr/local/include/node/cppgc/garbage-collected.h
  /usr/local/include/node/cppgc/heap.h
  /usr/local/include/node/cppgc/internal/accessors.h
  /usr/local/include/node/cppgc/internal/api-constants.h
  /usr/local/include/node/cppgc/internal/compiler-specific.h
  /usr/local/include/node/cppgc/internal/finalizer-trait.h
  /usr/local/include/node/cppgc/internal/gc-info.h
  /usr/local/include/node/cppgc/internal/logging.h
  /usr/local/include/node/cppgc/internal/persistent-node.h
  /usr/local/include/node/cppgc/internal/pointer-policies.h
  /usr/local/include/node/cppgc/internal/prefinalizer-handler.h
[about 500 more files]
```
After:
```
$ brew doctor
Unexpected header files:
  /usr/local/include/node/...
```
The full list of stray files can still be viewed with `brew doctor -v`.
2025-01-19 23:19:03 +08:00
Douglas Eichelberger
2d16333bbc Replace removable constants with overridable methods 2024-10-07 18:33:03 -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
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
apainintheneck
1fe16a5e35 Address feedback
- Move HOMEBREW_TAP_DIRECTORY to startup/config.rb because this file
holds more of the directory constants
- Rename `Commands.cmd_directories` to `Commands.tap_cmd_directories`
to better express that the commands come from taps

This file has the directory constants while the other one has regexes.
Just better organization.
2024-08-10 17:52:26 -07:00
apainintheneck
a3e917afe1 Refactor method to remove extra tap requires
We were selectively requiring the tap.rb file in a few places for
performance reasons. The main method we were referencing was the
`Tap.cmd_directories` method which uses `Pathname` and the `TAP_DIRECTORY`
constant internally. `Tap.cmd_directories` is mostly used in the `Commands`
module and that is loaded very early on in the program so it made sense
to move that command to that module. To facilitate that I moved the
`TAP_DIRECTORY` constant to the top-level and renamed it to
`HOMEBREW_TAP_DIRECTORY`. It now lies in the tap_constants.rb file.

A nice bonus of this refactor is that it speeds up loading external
commands since the tap.rb file is no longer required by default in
those cases.
2024-08-10 13:49:10 -07:00
Mike McQuaid
b8ff4b3d23
Widen attestation verification rollout
Take 2 of https://github.com/Homebrew/brew/pull/17692 but with:

- provide and document `HOMEBREW_NO_VERIFY_ATTESTATIONS`
- don't try to run unless there's GitHub credentials
- don't try to run unless `gh` is installed
- don't try to run in CI

While we're here:
- split out a `Homebrew::EnvConfig.devcmdrun?` helper method
- add some missing `Homebrew::EnvConfig.github_api_token` presence
  checks
2024-07-14 11:50:57 -04:00
Mike McQuaid
616646a1df
diagnostic: fix cask taps doctor output.
A fix for the previous fix broke the fix.
2024-06-11 10:23:39 +01:00
Mike McQuaid
68c5d616c2
diagnostic: don't show cask taps with no casks.
This avoids displaying a bunch of non-cask taps here.
2024-06-11 09:57:07 +01:00
Mike McQuaid
c13700af00
Use repository consistently instead of repo
The documentation linting job doesn't like `repo` so let's fix this
globally rather than naming it differently in documentation and code.
2024-06-10 09:31:53 +01:00
Mike McQuaid
16901a674f
extend/kernel: make opoo/odie/etc. print GitHub Actions notes.
We already do this for deprecations but these may make warnings
and errors from Homebrew easier to spot in GitHub Actions logs.

While we're here, cleanup other cases that should have used
`GitHub::Actions::Annotation` but didn't and provide some helpers and
tweaks there necessary for our use case here.
2024-05-09 14:43:53 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00