Relationships
#2812 serve: a relative grants-dir resolves against the working directory, not the repository
Opened by hammz · 9/30/2026· Shipped 10/1/2026
Summary
A relative grants-dir (from --grants-dir, SWAMP_GRANTS_DIR, or grants-dir: in .swamp/serve.yaml) is resolved against the process working directory, not the repository directory. The same serve config therefore loads different grants depending on where swamp serve was started from. For a daemon, it depends on the working directory the service manager uses.
Where
src/cli/commands/serve.ts(around line 3344):isAbsolute(merged.grantsDir) ? merged.grantsDir : resolve(merged.grantsDir).resolve()usesDeno.cwd(), notresolvedRepoDir.src/cli/commands/serve.ts:830:serve daemon installbuilds the daemon arguments withargs.push("--grants-dir", options.grantsDir)and passes a relative path through unchanged. The launchd/systemd service then resolves it against the daemon's own working directory, which need not be the directory wheredaemon installran.--grants-fileprobably behaves the same way and should be checked alongside.
Steps to reproduce
- Put
grants-dir: grantsin<repo>/.swamp/serve.yaml. - Run
swamp serve --repo-dir <repo>from a directory other than<repo>. - Serve either fails with "External grants directory not found: /grants", or loads a different directory that happens to exist there.
Expected
A relative grants-dir in the repository's serve config resolves against the repository directory. A relative CLI flag either does the same or is made absolute at daemon install time, so a daemon loads the same directory the operator named. Whichever rule is chosen should be documented in the --grants-dir help text and the serve-flags manual page.
Context
Found while triaging swamp-club#2788 (grants-dir files tracked under two source keys). The fix for #2788 compares directory identity, so the duplication is handled whichever base is used. The resolution base is a separate problem.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.