Relationships
#988 Support user systemd units for 'swamp serve daemon enable'
Opened by evrardjp · 7/6/2026· Shipped 7/6/2026
Problem
Running swamp serve daemon enable as a normal user attempts to write a system unit under /etc/systemd/system and fails with a raw permission error:
$ swamp serve daemon enable
14:49:07.570 fatal error { PermissionDenied: Permission denied (os error 13): writefile '/etc/systemd/system/.02708f58-9132-4a24-a821-c6dc9e330a63.tmp'
at async writeFile (ext:deno_fs/30_fs.js:916:7)
at async atomicWriteTextFile (file:///tmp/deno-compile-swamp/src/infrastructure/persistence/atomic_write.ts:41:5)
at async SystemdServiceScheduler.enable (file:///tmp/deno-compile-swamp/src/infrastructure/daemon/systemd_service_scheduler.ts:126:5)
at async Command.<anonymous> (file:///tmp/deno-compile-swamp/src/cli/commands/serve.ts:343:5)
at async Command.execute (https://jsr.io/@cliffy/command/1.0.1/command.ts:2307:7)
at async Command.parseCommand (https://jsr.io/@cliffy/command/1.0.1/command.ts:2140:14)
at async file:///tmp/deno-compile-swamp/src/cli/mod.ts:1371:7
at async runCli (file:///tmp/deno-compile-swamp/src/cli/mod.ts:1363:5)
at async file:///tmp/deno-compile-swamp/main.ts:42:5
code: "EACCES" }The command appears to expect root privileges but does not say so up front, and there is no obvious way to install the daemon as a per-user systemd unit.
Proposed solution
Add a --user option to swamp serve daemon enable that writes a user service unit (for example under the user systemd location) and enables it with systemctl --user semantics.
Also improve the default/root path behavior so that, when --user is not supplied and the current user cannot write /etc/systemd/system, the CLI reports an actionable error such as: run with sudo/root privileges, or use --user for a user service.
Alternatives
- Document that
swamp serve daemon enablemust be run as root for system units. - Automatically fall back to a user unit when root privileges are unavailable, though an explicit
--userflag is probably clearer.
Environment
Observed on a Linux host using systemd, as user, with swamp serve daemon enable.
Shipped
Click a lifecycle step above to view its details.