brew services: use package-provided service file when no run command - #23413
Closed
Yuxin-Qiao wants to merge 1 commit into
Closed
brew services: use package-provided service file when no run command#23413Yuxin-Qiao wants to merge 1 commit into
Yuxin-Qiao wants to merge 1 commit into
Conversation
Contributor
|
Thanks for your pull request. This has been closed because it appears to use an incomplete or outdated pull request template. Please edit this pull request to fill in the current pull request template. This workflow will reopen this pull request automatically once the template is complete. Do not open a new pull request for this. |
Restore the pre-Homebrew#23312 behaviour where `brew services start`/restart copied the service file installed by the formula into the keg instead of regenerating it from the `service do` block. Formulas that ship their own plist or systemd unit only define `name` (without `run`), so regenerating the file produces an invalid one with an empty ProgramArguments/ExecStart, and `launchctl bootstrap` fails with exit code 5. Only regenerate the service file when the formula defines a run command; otherwise fall back to the installed file. This matches the documented contract in the Formula Cookbook and the logic already used by FormulaInstaller#install_service. Fixes Homebrew#23408
Yuxin-Qiao
force-pushed
the
services-bundled-service-file
branch
from
August 3, 2026 19:23
a1bfbd6 to
8d356df
Compare
8 tasks
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.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?What this does
brew services start/restartagain uses the service file installed by the formula (the package-provided plist/systemd unit) when the formula'sservice doblock does not define aruncommand.PR #23312 changed
install_service_fileto always regenerate the service file from theservice doblock viaservice_contents. Formulas that ship their own service file only definename(withoutrun), so the regenerated plist had an emptyProgramArgumentsandlaunchctl bootstrapfailed with exit code 5 (Input/output error). Examples in homebrew-core:dbus,xinit.This restores the documented contract from the Formula Cookbook: if
nameis defined withoutrun, Homebrew makes no attempt to change the package-provided service file. It matches the logic already used byFormulaInstaller#install_service, which only writes a generated plist whenformula.service.command?is true.The per-service environment variable overrides from #23312 still apply whenever Homebrew generates the service file (i.e. when a
runcommand is defined).Why
PR #23312 unintentionally dropped support for package-provided service files, breaking
brew services startfor formulae that ship their own plist/systemd unit (e.g.dbus,xinitin homebrew-core). The generated file is invalid for such formulae because theservice doblock contains onlyname, solaunchctl bootstraprejects it with exit code 5.Step-by-step reproduction
Before this fix:
How it was verified
brew tests --only=services --no-parallel: 119 examples, 0 failuresbrew styleon the changed files: no offensesbrew typecheck: no errorsAI (Claude Code via Codex) was used to analyze the issue, implement the fix, and prepare this PR. The change was reviewed, typechecked with Sorbet, linted with RuboCop, and verified with the services test suite locally before submission.
Fixes #23408