Skip to content

service install checks linger, and prints the sudo line only when it's off - #89

Merged
edspencer merged 1 commit into
mainfrom
g-linger
Nov 5, 2026
Merged

edspencer merged 1 commit into
mainfrom
g-linger

Conversation

@edspencer

Copy link
Copy Markdown
Owner

Summary

cli-contract SPEC §7 ("Linger", a must): on Linux, service install must check loginctl show-user $USER -p Linger, and only when it's off print sudo loginctl enable-linger <user> and why; never run sudo. Until now install printed loginctl enable-linger $USER (without sudo) to everybody, as part of the systemd lifetime line, without checking.

  • server/service/linger.ts: lingerOf (moved from doctor.ts, unchanged), lingerUser, and lingerAdvice (the reference's lingerAdvice wording, but an unreadable answer gives nothing, per the task).
  • service install (Linux, not --dry-run, not --refresh) asks after the service answers. Off: a blank line, why, and sudo loginctl enable-linger <user>. On, or loginctl can't answer (no logind, a container): nothing.
  • --json: the advice leads the document's warnings (merged with the status report's), and the prose goes to stderr like the rest.
  • The systemd lifetime line is now just "It starts with your user session and is restarted if it exits."
  • Docs: "Running as a service" → Linux: linger now says "install and doctor check" (G-WORDING item 2), with sample output.
  • Patch changeset.

Testing

  • npm test (512 pass), npm run typecheck, docs site astro build.
  • New unit tests: linger off → the sudo line; on → nothing; unreadable → nothing; not asked on macOS / --dry-run / --refresh; --json puts it in warnings (and not on stdout). Control: with the old service/index.ts the three new positive tests fail.
  • Real-use QA: the packed tarball installed in a throwaway npm prefix and HOME, with a stand-in systemctl (runs the unit's ExecStart) and a stand-in loginctl on PATH: service install with Linger=no prints the advice, Linger=yes and a failing loginctl print nothing; --json stdout is one document whose warnings hold the advice; doctor still warns with fix: sudo loginctl enable-linger alex; uninstalled and cleaned up afterwards.

Checklist

  • User-facing change? It has a changeset.
  • UI change? No (CLI output and a docs page).
  • Doesn't weaken the read-only, never-delete or localhost-only guarantees.

🤖 Generated with Claude Code

…s off

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edspencer
edspencer merged commit e64b022 into main Nov 5, 2026
10 checks passed
@edspencer
edspencer deleted the g-linger branch November 5, 2026 09:17
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant