Skip to content

services/system: print warnings to stderr instead of stdout#21837

Merged
carlocab merged 1 commit intoHomebrew:mainfrom
stepbrobd:stderr
Mar 26, 2026
Merged

services/system: print warnings to stderr instead of stdout#21837
carlocab merged 1 commit intoHomebrew:mainfrom
stepbrobd:stderr

Conversation

@stepbrobd
Copy link
Copy Markdown
Contributor


  • 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 (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

in #21830

ac06ea7 seem to break my nix-darwin configuration as nix-darwin is executing the bundle command with root

https://github.com/nix-darwin/nix-darwin/blob/da529ac9e46f25ed5616fd634079a5f3c579135f/modules/homebrew.nix#L951

thus these two warning prints lines to stdout mess with json parsing

puts "Hide this warning by setting `HOMEBREW_SERVICES_NO_DOMAIN_WARNING=1`."

and im getting confusing errors like this:

Homebrew bundle...
Using stepbrobd/tap
Using resonative/proaudio
Using lyraphase/av-casks
Using nextfire/tap
Using apple-music-discord-rpc
Error: unexpected character: 'Hide' at line 1 column 1
Warning: Removed Sorbet lines from backtrace!
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/4.0.2/lib/ruby/4.0.0/json/common.rb:353:in 'JSON::Ext::Parser.parse'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/4.0.2/lib/ruby/4.0.0/json/common.rb:353:in 'JSON.parse'
/opt/homebrew/Library/Homebrew/bundle/brew_services.rb:68:in 'Homebrew::Bundle::Brew::Services.started_services'
/opt/homebrew/Library/Homebrew/bundle/brew_services.rb:58:in 'Homebrew::Bundle::Brew::Services.started?'
/opt/homebrew/Library/Homebrew/bundle/brew.rb:417:in 'Homebrew::Bundle::Brew#start_service_needed?'
/opt/homebrew/Library/Homebrew/bundle/brew.rb:443:in 'Homebrew::Bundle::Brew#service_change_state!'
/opt/homebrew/Library/Homebrew/bundle/brew.rb:369:in 'Homebrew::Bundle::Brew#install!'
/opt/homebrew/Library/Homebrew/bundle/brew.rb:43:in 'Homebrew::Bundle::Brew.install!'
/opt/homebrew/Library/Homebrew/bundle/installer.rb:70:in 'block in Homebrew::Bundle::Installer.install!'
/opt/homebrew/Library/Homebrew/bundle/installer.rb:56:in 'Array#each'
/opt/homebrew/Library/Homebrew/bundle/installer.rb:56:in 'Homebrew::Bundle::Installer.install!'
/opt/homebrew/Library/Homebrew/bundle/commands/install.rb:25:in 'Homebrew::Bundle::Commands::Install.run'
/opt/homebrew/Library/Homebrew/cmd/bundle.rb:235:in 'Homebrew::Cmd::Bundle#run'
/opt/homebrew/Library/Homebrew/brew.rb:115:in '<main>'

this can be reproduced with (remember to change the username, and e> syntax is for nushell only)

$ sudo --preserve-env=PATH --user=ysun --set-home env brew services list --json
Warning: running through sudo, using user/* instead of gui/* domain!
Hide this warning by setting `HOMEBREW_SERVICES_NO_DOMAIN_WARNING=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
[
  {
    "name": "apple-music-discord-rpc",
    "status": "started",
    "user": "ysun",
    "file": "/Users/ysun/Library/LaunchAgents/homebrew.mxcl.apple-music-discord-rpc.plist",
    "exit_code": 0
  }
]
$ sudo --preserve-env=PATH --user=ysun --set-home env brew services list --json e> /dev/null
Hide this warning by setting `HOMEBREW_SERVICES_NO_DOMAIN_WARNING=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
[
  {
    "name": "apple-music-discord-rpc",
    "status": "started",
    "user": "ysun",
    "file": "/Users/ysun/Library/LaunchAgents/homebrew.mxcl.apple-music-discord-rpc.plist",
    "exit_code": 0
  }
]

Copilot AI review requested due to automatic review settings March 25, 2026 22:36
@stepbrobd
Copy link
Copy Markdown
Contributor Author

cc @carlocab

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts brew services domain-selection messaging so warnings/hints don’t pollute machine-readable stdout (e.g., --json output), addressing downstream JSON parsing failures (notably when invoked via sudo in nix-darwin/Homebrew Bundle flows).

Changes:

  • Replace two puts hint lines with opoo so they emit on stderr instead of stdout.
  • Keep the “hide warning/hints” guidance gated behind HOMEBREW_NO_ENV_HINTS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@carlocab
Copy link
Copy Markdown
Member

Thanks; I think at least the first, if not both, copilot review comments need addressing.

@stepbrobd
Copy link
Copy Markdown
Contributor Author

thanks for getting back so quickly! i've addressed the first one but i'm not very familiar with the code base so i'm not sure how to get started on the second one

maybe that could be done in another pr by someone else?

Copy link
Copy Markdown
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@carlocab carlocab enabled auto-merge March 26, 2026 01:30
@carlocab carlocab added this pull request to the merge queue Mar 26, 2026
Merged via the queue into Homebrew:main with commit b54c872 Mar 26, 2026
38 checks passed
@stepbrobd stepbrobd deleted the stderr branch March 26, 2026 07:57
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