Support (and set) launchd
user domain target
#588
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running
brew services
overssh
orsudo
as a non-root
user thegui
domain target forlaunchd
does not work as expected. This produces confusing failures for users.It was tried before to detect if this was needed from the
.plist
or changing globally but both approaches were unsuccessful/error-prone.Instead, use the
user
domain automatically on the cases we know it's needed: when running overssh
or throughsudo
. To make clear to users what's happening in these cases: output a warning (which can be hidden with an output environment variable).For this to work,
launchctl list
is no longer sufficient. The output here, even when run asroot
, does not properly listuser
domain services. Instead, we need to uselaunchctl print
to correctly query the status of these services. This also seems to correctly handle somelaunchd
edge-cases where launched services cannot be detected and letsbrew services
now stop them.While we're here, fix some related issues I came upon while working on this:
brew services
command documentation to note it now runs on Linux/systemd
toonamed_args
and remove thecustom_plist
deprecation: it's been long enough and this cleans up the code nicely.:other
(an edge-case that shouldn't be possible in normal operation): actually output this rather than failing with anil
errorlaunchctl list
multiple times when unnecessarybrew services --debug
now outputs the raw output fromlaunchctl
orsystemctl
to aid debugging/developmentplist?
System.systemctl_args
to avoid repeatingSystem.systemctl
andSystem.systemctl_scope
in every call siteDepends on Homebrew/brew#16041 to detect
sudo
orssh
correctly.