Relationships
#4704 local_encryption vault base_dir does not expand $HOME, unlike datastore.path
Opened by ehazlett · 11/13/2026· Shipped 11/13/2026
Observed with swamp 20261112.171308.0.
Confidence: high — reproduced in a scratch repository.
.swamp.yaml's datastore.path expands $HOME, so
path: $HOME/.state/datastore resolves correctly in every checkout. A
local_encryption vault's base_dir expands nothing. The vault config lives in
vaults/local_encryption/<id>.yaml, which is version-controlled with the
repository, so an absolute base_dir written on one machine is carried to
every other checkout verbatim:
# written on a Linux machine, committed, then pulled on a macOS machine
config:
auto_generate: true
base_dir: /home/[REDACTED]/.state/vaultOn the second machine the path does not exist, and vault list-keys reports
zero keys without saying why. (Writing to the vault there was not tried.)
Putting a variable in the path does not help, because it is treated as literal text:
swamp vault create local_encryption w --config '{"auto_generate":true,"base_dir":"$VTEST/vault"}'
echo s3cret | VTEST=/some/dir swamp vault put w k
# → secrets written to <repo>/$VTEST/vault, a directory literally named "$VTEST"
swamp vault create local_encryption h --config '{"auto_generate":true,"base_dir":"$HOME/../../<abs-path>/hv"}'
echo s3cret | swamp vault put h k
# → "$HOME" is taken as a folder name inside the repo and cancelled by the "..",
# so the secret lands under <repo>/../<abs-path>/hv; $HOME was never expandedImpact: a repository whose datastore lives outside the checkout (the setup
swamp datastore setup filesystem --path encourages) cannot keep its vault
beside it portably. Every option breaks one of them:
- An absolute path works on one machine only.
- A relative path resolves from the repository, so it breaks if the checkout is moved.
- Leaving
base_dirunset puts the secrets inside the checkout, away from the datastore.
The two settings name the same kind of location but follow different rules,
which is easy to miss. The datastore expanding $HOME suggests the vault does
too.
Ask: expand $HOME in local_encryption base_dir the way
datastore.path does (and in key_file too, if that has the same problem; it
was not tested), when the vault is used rather than when it is stored.
Separately, when base_dir does not exist, vault list-keys should say so
instead of reporting an empty vault.
Shipped
Click a lifecycle step above to view its details.
zack commented 11/13/2026, 3:41:16 PM
Thanks @ehazlett for reporting this! We shipped: Expand a leading tilde or HOME in local_encryption base_dir, key_file and ssh_key_path when the vault is used (never in stored config), resolve a relative base_dir against the repo like datastore.path, and make vault list-keys report a missing base_dir instead of an empty vault. Only HOME is expanded, not arbitrary variables, so committed config cannot leak env values. An expansion failure stays scoped to the one vault.. The fix has been merged and a release is on its way. We appreciate your contribution to swamp.
ehazlett commented 11/13/2026, 11:50:08 PM
❤️
Sign in to post a ripple.