diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 14:15:23 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 14:15:28 +0000 |
| commit | 8096fde8d98cdde4e110865ebb15ad034b92ff27 (patch) | |
| tree | f3d207f4216280d46866af6441b30e6cc80d84c0 /docs/DECISIONS.md | |
| parent | 153e72cc797c1e45a60f4896d00163fb4bdf3056 (diff) | |
| download | aur-build-8096fde8d98cdde4e110865ebb15ad034b92ff27.tar.gz aur-build-8096fde8d98cdde4e110865ebb15ad034b92ff27.zip | |
config: the root is the directory config.json lives in
`--root` names a directory and `init` writes config.json inside it, so the root
was already named by where the config lived. The `root` field in the file was
treated as a second source of truth instead: a relative one was re-joined onto
the config's own directory, and `init` saved whatever it had been handed. So
`--root runtime` wrote `"root": "runtime"`, and every command after `init`
resolved it to `runtime/runtime/` — a second tree with its own empty database,
while `init` had created and migrated the first one. The user-visible half was a
path like `runtime/runtime/repo/aur-build/os/x86_64/…` in an error message.
Compounding it, the CLI fell back to a default config whenever loading failed, so
a typo'd `--root` produced a fresh empty server that answered every command as
though it were the one you meant. `load` now sets the root to the directory it
found the config in, absolutized, and a missing config is an error for every
command except `init` — the only one that runs before one exists.
Diffstat (limited to 'docs/DECISIONS.md')
| -rw-r--r-- | docs/DECISIONS.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index bded52a..58d694a 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -427,3 +427,26 @@ missing. the rejection has to be updated if pacman's rule changes. That is the correct failure: a shim drifting from its tool should break a test loudly, not let a production path go untested. +## The root is the directory `config.json` lives in + +`--root` selects a directory and `init` writes `config.json` inside it, so the +root is already named by the location of the config. The `root` field in the file +was treated as a second source of truth: a relative one was re-joined onto the +config's own directory, and `init` saved whatever it had been handed. So +`--root runtime` wrote `"root": "runtime"`, and every command after `init` +resolved that to `runtime/runtime/` — a second tree, with its own empty database, +while `init` had created and migrated the first one. Compounding it, the CLI fell +back to a default config whenever loading failed, so a typo'd `--root` produced a +fresh empty server that answered every command as if it were the real one. + +**Choice.** `Config::load` sets the root to the directory it found the config in, +absolutized; the field in the file is a record for whoever is reading the tree, +and `save` writes it absolute so it stays readable. A missing config is an error +for every command except `init`, which is the only one that runs before one +exists. + +**Cost.** A hand-edited absolute `root` in a config file no longer relocates a +tree — you move the directory and point `--root` at it, which is how the CLI +already worked. And an existing tree that was already split by the doubling keeps +its two databases until someone notices and moves the rows; the fix stops the +bleeding rather than reconstructing what went into the wrong tree. |
