Skip to content

.env.example cannot document a variable without making it an override #865

Description

@Chemaclass

src/env.sh loads .env with set -o allexport; source .env, so every line in it is an unconditional assignment. Adding a variable to .env.example purely as documentation therefore breaks that variable's env-var form as soon as anyone copies the file:

# with BASHUNIT_OUTPUT_FORMAT= present in .env
BASHUNIT_OUTPUT_FORMAT=tap ./bashunit tests/   # silently ignored

CI hits this directly — tests.yml has a Setup Config step that runs cp .env.example .env. This caused 12 red jobs on #862 and was invisible locally, because a developer's existing .env predates any newly added key.

.bashunitrc does not have the problem: bashunit::env::load_config_file applies each key with ${key:-val}, i.e. only when unset.

The bind is that .env.example is currently both the starter config and the reference documentation, and those two roles now conflict. Options:

  1. Load .env with the same apply-when-unset semantics as .bashunitrc (changes precedence — needs a decision on whether .env should beat an exported variable).
  2. Keep .env.example minimal and move the full variable reference to docs/configuration.md.
  3. Ship the reference entries commented out.

A stopgap comment was added in #862 warning not to add variables there, but the underlying conflict stands.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions