[Fix] Resolve LaunchAgent plist path for external homes#89092
Conversation
Signed-off-by: samzong <[email protected]>
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open for maintainer decision: the central daemon fix is now covered by a clean, proof-positive canonical PR, but this branch also contains unique macOS app snapshot work and is not merge-ready because it is conflicting and remaps arbitrary custom homes too broadly. Canonical path: Close this PR as superseded by #90923. So I’m closing this here and keeping the remaining discussion on #90923. Review detailsBest possible solution: Close this PR as superseded by #90923. Do we have a high-confidence way to reproduce the issue? Yes. Current main source still derives the daemon and app plist paths from HOME, and the PR body plus linked issue show the external-APFS launchd error path; I did not run a live macOS APFS repro in this Linux checkout. Is this the best way to solve the issue? No. A shared daemon resolver is the right layer, but this branch's resolver is too broad and the clean overlapping PR is the better daemon fix; the only possible remainder is a narrower Swift app reader follow-up. Security review: Security review cleared: No concrete security or supply-chain concern found; the diff changes local launchd path resolution and tests without dependencies, workflows, permissions, or secret handling. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against e99ab385cfe1. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3c8b95bb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const userName = extractUserNameFromHomePath(home) ?? resolveShortUserName(env); | ||
| return userName ? path.posix.join("/Users", userName) : home; |
There was a problem hiding this comment.
Don't remap arbitrary custom homes to /Users
When a macOS account has a nonstandard home that does not end in /Users/<shortName> (for example /var/root, /Volumes/HomeDisk/alice, or a managed/network home) but USER/LOGNAME is present, this fallback now resolves the LaunchAgent location to /Users/<name>/Library/LaunchAgents/... instead of the actual home directory that the previous code used. That means install/restart/uninstall can bootstrap or create a plist in a directory unrelated to the user's configured home; the external-volume fix should only remap paths that actually match the /.../Users/<name> shape, and otherwise preserve home rather than falling back to env user names.
Useful? React with 👍 / 👎.
|
ClawSweeper applied the proposed close for this PR.
|
Summary
What problem does this PR solve?
HOMEpoints at an external volume, such as/Volumes/ExternalDrive/Users/alice./Users/alice/Library/LaunchAgents/ai.openclaw.profile.plist.src/daemon/launchd-path.tsand mirrors the behavior in the macOS app LaunchAgent manager.Why does this matter now?
What is the intended outcome?
What is intentionally out of scope?
What does success look like?
HOME=/Volumes/ExternalDrive/Users/alice, OpenClaw writes and bootstraps/Users/alice/Library/LaunchAgents/ai.openclaw.profile.plist; no plist is created under the external HOME LaunchAgents directory.What should reviewers focus on?
/.../Users/alicehomes.Linked context
Which issue does this close?
N/A - no tracked issue.
Which issues, PRs, or discussions are related?
N/A - no related public issue or PR was provided.
Was this requested by a maintainer or owner?
N/A - prepared from a local ship request for this branch.
Real behavior proof (required for external PRs)
HOMEis on an external APFS volume.x, Node v24.14.0, source OpenClaw CLI, temporary APFS disk image mounted at/Volumes/OpenClawProof-final-1780319982, isolatedOPENCLAW_PROFILE=proof-1780319414, isolated config and state directories under/tmp.HOME=/Volumes/OpenClawProof-final-1780319982/Users/x, rannode --import tsx src/entry.ts gateway install --force --port 19037 --wrapper /tmp/.../openclaw-source-wrapper --json, checked the boot-volume plist path, checked the external-home plist path, checkedlaunchctl print gui/$UID/ai.openclaw.proof-1780319414, and checkedcurl -fsS http://127.0.0.1:19037/healthz. Then rangateway uninstall --json, removed the temp plist/trash artifact if present, and detached the disk image./Users/x/Library/LaunchAgentsplist, did not create the plist under the mounted external HOME, and the temporary Gateway answered/healthz./Volumes.HOME, so an externalHOME=/Volumes/ExternalDrive/Users/aliceresolved to/Volumes/ExternalDrive/Users/alice/Library/LaunchAgents/ai.openclaw.profile.plistinstead of/Users/alice/Library/LaunchAgents/ai.openclaw.profile.plist.Tests and validation
Which commands did you run?
git diff --cached --checkOPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN=false node scripts/check-changed.mjs --base upstream/main --head HEADnode scripts/run-vitest.mjs src/daemon/launchd-path.test.ts src/daemon/launchd.test.ts src/daemon/launchd-restart-handoff.test.ts src/infra/restart.test.ts src/cli/update-cli/restart-helper.test.tsswift test --skip-update --filter GatewayLaunchAgentManagerTestsWhat regression coverage was added or updated?
src/daemon/launchd-path.test.tsfor boot-volume home preservation, external APFS HOME remapping, missing HOME fallback, invalid short-name fallback, and plist path construction.What failed before this fix, if known?
HOMEvalues, which points at the wrong LaunchAgents directory for the launchd user agent.If no test was added, why not?
N/A - regression tests were added and updated.
Risk checklist
Did user-visible behavior change? (
Yes/No)Yes - macOS LaunchAgent commands and hints now prefer the boot-volume user LaunchAgents path for external-home setups.
Did config, environment, or migration behavior change? (
Yes/No)No - config shape and migration behavior are unchanged.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)No.
What is the highest-risk area?
How is that risk mitigated?
/Users/alicehomes are preserved./.../Users/alicehomes prefer the short name parsed from the path itself.Current review state
What is the next action?
What is still waiting on author, maintainer, CI, or external proof?
Which bot or reviewer comments were addressed?
N/A - no review comments yet.