Skip to content
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

feat: Add brew doctor --ignore-warnings #17864

Closed
wants to merge 1 commit into from

Conversation

9999years
Copy link

@9999years 9999years commented Jul 25, 2024

When brew doctor is run, brew exits with a non-zero status if any warnings or errors are encountered. However, this groups warnings and errors together, but (as the output notes) warnings can be innocuous:

Please note that these warnings are just used to help the Homebrew
maintainers with debugging if you file an issue. If everything you use
Homebrew for is working fine: please don't worry or file an issue;
just ignore this. Thanks!

The --ignore-warnings switch makes it possible for automated tools interacting with Homebrew to distinguish between warnings and hard errors.

$ brew doctor --ignore-warnings
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed casks are deprecated or disabled.
You should find replacements for the following casks:
  graphql-playground
$ echo "$?"
0

Hard errors will still cause a non-zero exit status:

$ brew doctor --ignore-warnings
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: gettext files detected at a system prefix.
These files can cause compilation and link failures, especially if they
are compiled with improper architectures. Consider removing these files:
  /opt/homebrew/lib/libgettextlib.dylib
  /opt/homebrew/lib/libintl.dylib
  /opt/homebrew/include/libintl.h
Error: unknown or unsupported macOS version: :dunno
$ echo "$?"
1
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

When `brew doctor` is run, `brew` exits with a non-zero status if any
warnings or errors are encountered. However, this groups warnings and
errors together, but (as the output notes) warnings can be innocuous:

> Please note that these warnings are just used to help the Homebrew
> maintainers with debugging if you file an issue. If everything you use
> Homebrew for is working fine: please don't worry or file an issue;
> just ignore this. Thanks!

The `--ignore-warnings` switch makes it possible for automated tools
interacting with Homebrew to distinguish between warnings and hard
errors.

```
$ brew doctor --ignore-warnings
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed casks are deprecated or disabled.
You should find replacements for the following casks:
  graphql-playground
$ echo "$?"
0
```

Hard errors will still cause a non-zero exit status:

```
$ brew doctor --ignore-warnings
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: gettext files detected at a system prefix.
These files can cause compilation and link failures, especially if they
are compiled with improper architectures. Consider removing these files:
  /opt/homebrew/lib/libgettextlib.dylib
  /opt/homebrew/lib/libintl.dylib
  /opt/homebrew/include/libintl.h
Error: unknown or unsupported macOS version: :dunno
$ echo "$?"
1
```
@MikeMcQuaid
Copy link
Member

The --ignore-warnings switch makes it possible for automated tools interacting with Homebrew to distinguish between warnings and hard errors.

There is no distinction in brew doctor made between warnings and errors.

Automated tools should either avoid running brew doctor at all or ensure that all warnings are fixed if it's essential that it passes.

Error: unknown or unsupported macOS version: :dunno

This is not a brew doctor warning, it's a random Homebrew warning that will trigger from many other commands.

@9999years
Copy link
Author

This is not a brew doctor warning, it's a random Homebrew warning that will trigger from many other commands.

I understand that (although perhaps it should be a brew doctor error). What command would you recommend I run to check for this error, if not brew doctor?

@MikeMcQuaid
Copy link
Member

What command would you recommend I run to check for this error, if not brew doctor?

How are you triggering this error? It seems like you're on an unknown macOS version?

@9999years
Copy link
Author

I maintain a developer environment bootstrapping tool which (among other things) installs Homebrew and then PostgreSQL with Homebrew. I'm working on a feature to upgrade the PostgreSQL installation. However, we only use Homebrew for PostgreSQL, so developers rarely update it on their own. As a result, we have a bunch of engineers running macOS Sonoma with versions of Homebrew too old to support macOS Sonoma.

I can solve this with brew update, but the tool tries to avoid doing unnecessary work, so I'd like to avoid it if possible. Therefore, I'd like to detect if the current version of macOS is supported by the current version of Homebrew.

Ideally, I'd also like to catch any other show-stopper errors with the Homebrew installation, and I was hoping I could use brew doctor for this purpose.

@9999years
Copy link
Author

BTW I appreciate you taking the time to talk this over! I would've included more context in the original PR description but I thought the feature was uncontroversial enough that it wasn't warranted.

@9999years 9999years marked this pull request as ready for review July 25, 2024 19:42
@Bo98
Copy link
Member

Bo98 commented Jul 25, 2024

That error isn't an intentional from brew doctor - it's just you hitting a code path that is immediately aborting on an invalid macOS. If it was an intentional error it would have a proper message and wouldn't abort immediately. This is technically a bug so could be fixed if someone finds where it breaks.

You could try brew doctor check_for_unsupported_macos. It does however also check for old macOS that are semi-unsupported (i.e. Big Sur and earlier).

@MikeMcQuaid
Copy link
Member

Sorry, passing on this PR but hopefully @Bo98's suggested workaround is useful.

@9999years 9999years deleted the add-ignore-warnings branch July 26, 2024 17:19
@9999years
Copy link
Author

@Bo98 Thanks, brew doctor check_for_unsupported_macos works great for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants