salt
salt copied to clipboard
modules.mac_brew_pkg: don't use sudo -i
What does this PR do?
sudo -i is used for starting interactive sessions. It causes sudo to tell the shell to run a login session, which triggers reading e.g. ~/.bash_profile.
Since that's intended for interactive use cases, it may produce output. But any output on stdout will be read as brew's json output - breaking states.pkg.
What issues does this PR fix or reference?
Fixes: https://github.com/saltstack/salt/issues/62394
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
- [ ] Docs
- [ ] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
- [ ] Tests written/updated
Commits signed with GPG?
Yes/No
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.
@rvandegrift Are you able to add a changelog file and a test for this?
I expect this to break for any host on Apple Silicon since brew is not in PATH by default there. The only way I see around that is
--preserve-env=PATHand telling users to addbrewto PATH for root.
From [1], it sounds like they plan to move brew to /opt/homebrew on all platforms eventually. Seems like salt should hardcode that path (or at least check it first - though admittedly, it's annoying to have to re-implement PATH).
[1] - https://github.com/Homebrew/brew/issues/7857
@rvandegrift Are you able to add a changelog file and a test for this?
Sorry I'm not too keen on doing release management work, especially with the specific requests about changelog format.
As a homebrew maintainer I can assure you, there are no plans to move the install location on x86 macs. Eventually all macs will be ARM and therefore /opt/Homebrew by default though. But that doesn't account for systems where homebrew is installed in a custom location (like in a lot of big companies).
Essentially this change is a big regression in favor of a niche bugfix from my point of view.
@rvandegrift, given @SMillerDev 's comments, I do think we should allow this as an option to the mac pkg commands. Something like interactive=True by default.