services: recognize both Linux service labels - #23792
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Moderate issues can leave running services behind or dangling systemd symlinks.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds support for both legacy and canonical Linux systemd service labels across discovery, lifecycle management, and Bundle lookup.
Changes:
- Exposes compatible systemd labels and paths.
- Updates service/timer discovery, status, lifecycle, and cleanup.
- Adds tests for aliases, timers, probes, and Bundle lookup.
Required fixes:
services/cli.rb: Do not remove a unit file whensystemctl disablefails (moderate).services/cli.rb: Always include a running service label when stopping or killing timed formulae, even if another timer is active (moderate).services/formula_wrapper.rb: Probe service units as well as timers for every compatible label (moderate).
File summaries
| File | Description |
|---|---|
Library/Homebrew/utils/service.rb |
Probes compatible systemd units. |
Library/Homebrew/test/utils/service_spec.rb |
Tests compatible service probes. |
Library/Homebrew/test/services/formula_wrapper_spec.rb |
Tests wrapper discovery and timers. |
Library/Homebrew/test/services/cli_spec.rb |
Tests lifecycle and cleanup behavior. |
Library/Homebrew/test/formula_spec.rb |
Tests service names and systemd paths. |
Library/Homebrew/test/bundle/brew_services_spec.rb |
Tests compatible Bundle lookup. |
Library/Homebrew/services/formula_wrapper.rb |
Discovers, caches, and probes compatible units. |
Library/Homebrew/services/cli.rb |
Controls and removes compatible units. |
Library/Homebrew/service.rb |
Defines compatible Linux service labels. |
Library/Homebrew/formula.rb |
Exposes compatible systemd paths. |
Library/Homebrew/bundle/brew_services.rb |
Finds compatible versioned service files. |
Review details
Suppressed comments (1)
Library/Homebrew/services/cli.rb:350
- This fallback has the same mixed-timer gap as
stop: for timed services, a non-emptyloaded_service_namesmay identify an active compatible timer whileactive_service_nameidentifies a different compatible unit holding the PID. In that statekillstops only the timer's service label and leaves the actual process running. Include the active label as well.
killed_service_names = service.loaded_service_names.presence || [service.active_service_name]
- Files reviewed: 11/11 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
p-linnane
force-pushed
the
services-compatible-linux-labels
branch
from
September 5, 2026 00:28
6bb94af to
d147207
Compare
Signed-off-by: Patrick Linnane <patrick@linnane.io>
p-linnane
force-pushed
the
services-compatible-linux-labels
branch
from
September 5, 2026 00:40
d147207 to
8c83898
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
brew servicesassumes a Linux service is always namedhomebrew.<formula>. This is phase one of moving that default tosh.brew.<formula>, mirroring #23741 for macOS: discovery and control now accept either systemd unit name, so both forms can coexist safely before the default is flipped. The unit name written to disk does not change here.Formulae using the default Linux name expose both names. An explicit
name linux:stays single valued even when it matches a default, and now serializes explicitly so it survives the later default change; aFormulasubclass overridingservice_namekeeps its custom identity. Status probes every compatible unit and reports the one holding the PID;stopandkillact on the exact units found, including a running service whose timer is inactive;startandrunwill not register a second unit when the alternate name is already loaded; orphan cleanup stays pinned to the unit it discovered.brew bundleversion pinned lookup and theUtils::Serviceprobes accept either unit filename.Unit files are only removed after
systemctl disable, so replacing or unregistering the alternate name cannot leave a dangling.wantssymlink. Timers are regenerated from the formula, and a package-provided timer only has itsUnit=rewritten when it names a compatible label. An accepted--no-waitstop still cleans up. Status probes are cached per wrapper and invalidated after every mutation. macOS and launchd behavior is unchanged.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Fable 5.1) drafted the implementation and tests; I reviewed the diff, verified the new tests fail without the change and pass with it, and ran
brew lgtm --online.