actions / runner-images

GitHub Actions runner images
MIT License
9.31k stars 2.89k forks source link

Warnings/errors from "brew edit" commands being routed to standard output. #9874

Closed btb closed 4 weeks ago

btb commented 1 month ago

Description

This unusual routing prevents the normal output from being captured in a variable and used.

I see the problem doesn't occur on the macos-11 runner, but it does occur on every other macos runner I tried. I see that the version of homebrew is older on the macos-11 runner (4.2.5) whereas the other runners use homebrew 4.3.0. But I don't think this is the whole problem, since I cannot reproduce this problem on my own machine running macos 14 and homebrew 4.3.0.

Platforms affected

Runner images affected

Image version and build link

20240514.3

Is it regression?

yes

Expected behavior

When using a command brew edit --print-path [formula] the result should be printed on stdout, allowing you to capture the output for use in other commands. Any warnings should be printed on stderr.

    sdl_image_formula=$(brew edit --print-path sdl_image)
    echo sdl_image_formula: $sdl_image_formula

should result in something like:

Warning: edit is a developer command, so Homebrew's
developer mode has been automatically turned on.
To turn developer mode off, run:
  brew developer off

Warning: `brew install` ignores locally edited casks and formulae if
HOMEBREW_NO_INSTALL_FROM_API is not set.
sdl_image_formula: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/s/sdl_image.rb

where you see the errors/warnings as the command is run, then you see the captured formula path afterward.

Here's a run showing that it used to work in macos-14-arm64: https://github.com/btb/d2x/actions/runs/8953473131/job/24592024810

Here's a run showing it still works normally using the macos-11 runner: https://github.com/btb/d2x/actions/runs/9121219819/job/25080022032

Actual behavior

The warnings/errors are somehow being routed to the standard output, so they are improperly captured in the variable.

    sdl_image_formula=$(brew edit --print-path sdl_image)
    echo sdl_image_formula: $sdl_image_formula

results in:

Warning: edit is a developer command, so Homebrew's
developer mode has been automatically turned on.
To turn developer mode off, run:
  brew developer off

Warning: `brew install` ignores locally edited casks and formulae if
HOMEBREW_NO_INSTALL_FROM_API is not set.
sdl_image_formula: ::warning::`brew install` ignores locally edited casks and formulae if%0AHOMEBREW_NO_INSTALL_FROM_API is not set.%0A /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/s/sdl_image.rb

Here's the run where it stopped working in macos-14-amd64: https://github.com/btb/d2x/actions/runs/9120125848/job/25077018332

Repro steps

Run the 'brew edit' command in a "run" shell, and capture its output to a variable .

erik-bershel commented 1 month ago

Hey @btb!

Good first issue. I cannot reproduce faulty behaviour on my macOS-14 too. Seems to be the real case. We'll check what might be done to resolve it.

sergei-pyshnoi commented 4 weeks ago

Hello @btb . After investigation we found that problem could be in new runner version. Behavior also reproducible using self-hosted runner on local MacOS machine , so unfortunately we cannot do nothing from our side with it. You can create issue in runner repo for fixing it in a future. As workaround you can enable brew developer mode and set HOMEBREW_NO_INSTALL_FROM_API variable in runtime for avoiding warnings. I am closing issue but you if you have additional questions feel free to reach me out.