Skip to content

fix(update): report failure when systemctl will not start the update timer - #282

Merged
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/update-timer-systemctl-enable-ignored
Aug 4, 2026
Merged

fix(update): report failure when systemctl will not start the update timer#282
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/update-timer-systemctl-enable-ignored

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

What

moshcode update --timer --install writes the systemd units, runs systemctl daemon-reload and systemctl enable --now moshcode-update.timer, then always prints checking on a schedule now and exits 0 — even when the enable fails.

On a host without systemd (a container, WSL, macOS) or without root, the timer never starts. The user is told their machine is auto-updating on a schedule when it is not. Silent, and exactly the kind of promise you only discover was empty when the update you were counting on never happened.

Two layers were dropping the failure:

  • bin/moshcode.mjs wired runner as execFile(cmd, args, () => res({ ok: true })) — the callback ignores execFile's error and always resolves { ok: true }, so selfUpdateCommand could never see a failure.
  • src/selfupdate.mjs ignored the runner results entirely and printed success unconditionally.

Fix

  • Surface execFile's error: (err) => res({ ok: !err }).
  • In selfUpdateCommand, when daemon-reload or enable reports ok:false, tell the user the timer is not scheduled yet and return 1 instead of claiming success.

The existing tests already inject runner: () => ({ ok: true }), so the { ok } contract is the intended one — this change just honors the failing side of it.

Evidence (real selfUpdateCommand, systemctl enable failing)

Before:

exit code: 0
units written: 2
checking on a schedule now. `systemctl list-timers moshcode-update` to see when.

After:

exit code: 1
units written: 2   (still written — we just do not lie about the timer)
moshcode update: wrote the units but systemctl could not start the timer — it is not checking on a schedule yet. run `systemctl enable --now moshcode-update.timer` as root.

Tests

New regression test in test/selfupdate.test.mjs: with systemctl enable returning ok:false, asserts exit 1, units still written, no "checking on a schedule now", and the failure message. Fails before this change, passes after.

Controls unchanged: the ok:true install path still prints checking on a schedule and returns 0.

Full suite green: 1215 tests, 1002 pass, 0 fail, 213 skipped. Two source files + one test file; generated package-lock.json removed before commit.

…timer

`moshcode update --timer --install` writes the systemd units, runs
`systemctl daemon-reload` and `systemctl enable --now`, then always
prints "checking on a schedule now" and exits 0 — even when the enable
fails. On a host without systemd (a container, WSL, macOS) or without
root, the timer never starts, so the tool promises an auto-update that
will never fire.

Two layers were dropping the failure:
- bin/moshcode.mjs wired `runner` to swallow execFile's error and always
  resolve { ok: true }, so selfUpdateCommand could never see a failure.
- selfUpdateCommand ignored the runner results entirely.

Surface execFile's error as { ok: !err }, and when daemon-reload or
enable reports ok:false, tell the user the timer is not scheduled yet
and exit 1 instead of claiming success. The existing tests already
inject runner: () => ({ ok: true }), so the { ok } contract is honored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio
ralyodio merged commit d89e06c into moshcoder:main Aug 4, 2026
4 checks passed
@ralyodio ralyodio mentioned this pull request Aug 4, 2026
ralyodio added a commit that referenced this pull request Aug 4, 2026
A Moshpit name now survives the TLS handshake without a per-name detour.
`dns trust <name>` installs the leaf a name serves, but only when its key
matches a pin the registry already published, and `dns start --trust-all`
does that as names resolve (#279, #281). Minor, not patch: two new ways to
invoke the tool.

Also carries two commands that used to report success they had not earned
-- `update --timer --install` when systemctl refused (#282), and
`site --proxy` with a port outside 1-65535 (#280).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

2 participants