Skip to content

env

A config reads the environment — {{ env.X }} in a template, match: { env: … } on a target — and nothing told you which. This does.

Terminal window
$ bedouin env
Variables this config reads:
BEDOUIN_PROFILE set targets.work (a target; unset just means it will not match)
GIT_SIGNING_KEY not set vars.signing_key
ZELLIJ_VERSION not set packages.zellij (has a default)
2 of 3 unset.
1 of those has no default and will fail to resolve.

Names and set-or-not, never values — the same rule as bedouin facts, for the same reason: this output ends up in bug reports.

The scan reaches inside the files a files: entry points at, not just the YAML. A {{ env.GIT_USER_NAME }} that lives in templates/gitconfig.j2 is read at render time, so it is listed here — and, just as importantly, frozen into a saved plan. It is also only a reference inside {{ … }} or {% … %}: an rc file named 40-direnv.zsh contains the letters env. and is not a variable.

The last column matters. A variable behind | default(…) cannot fail. One read by a match: cannot fail either — the target just does not match. A bare {{ env.X }} with nothing set is a resolve-time failure waiting to happen, and plan warns about exactly those.

Terminal window
$ bedouin env --write
Wrote ./.env.bedouin
Bedouin reads it before resolving facts, so what you put there takes effect.
Added it to ./.gitignore

It writes a commented file listing every variable, with the ones already set left commented out so filling in a blank cannot silently shadow something that is working.

Your shell wins over the file: what you exported for this command is more specific than what the file says in general.

Terminal window
$ GIT_SIGNING_KEY=FROMSHELL bedouin apply # beats the file

bedouin env deliberately runs without resolving the config — a config that will not resolve is usually exactly the one you need this for.