Repository navigation
bug(scripts): detect-environment.sh selects three .env files that do not exist #15143
Description
Activity
- addedarea: ci-gatesWave 0 · cluster P — CI gates & merge integrityWave 0 · cluster P — CI gates & merge integrity
on Sep 1, 2026 Post-merge closure audit: both ACs verified on
mainat 0abe0d4. Fixed by PR #16553, merge commit dadd176.-
"Every branch selects a file the repo actually provides, or fails with a message naming what is missing rather than exporting nothing." ✅ I took the branches from
detect_environment()'s five possible outputs and checked each againstdetect-environment.sh:wsl-docker-desktopselects.env.localhost(:43-46).linux-native,wsl-native-dockerandcontainerizedshare one branch that runsexit 1(:48-56). It prints "No environment file is mapped for '' yet (bug(scripts): detect-environment.sh selects three .env files that do not exist #15143)" and lists the tracked files.*, which catchesno-docker, selects.env.localhost(:58-60).
.env.localhostis tracked at the repo root onmain; it is one of the 6 root.env*files. -
"A test asserts each selectable env-file name against the tracked set, and fails if that set is empty." ✅ In
repo_tests/detect_environment_env_files_test.py::68test_resolved_branches_select_a_tracked_fileasserts that the selected file is in_tracked_env_files().:63test_the_tracked_set_is_not_emptyfails if the set is empty.- A Reach floor of 6 (
:44) catches the set shrinking. - Caveat:
_tracked_env_files(:32-34) globs the working tree rather than callinggit ls-files. The two are identical in a clean CI checkout, but an untracked local.env*file would count as tracked.
Outside these ACs:
ENV_FILEis relative to the current directory. If the script is sourced from anywhere other than the repo root, the selected file is reported "not found, using defaults" (:69). This behaviour predates the PR.-
Found while resolving the first batch of #15127.
autobot-infrastructure/shared/scripts/utilities/detect-environment.shpicks an env file perdetected environment and then
exports it. Four of the five branches name a file that is nottracked anywhere in the repo:
.env.wsl-docker-desktop.env.linux-native.env.linux-native.env.distributed.env.localhostThe tracked env files are
.env.docker,.env.example,.env.localhost,.env.native-vm,.env.network,.env.network-templateanddocker/.env.docker. The generator and validator thatown this inventory —
generate-env-files.pyandvalidate-env-files.py— know onlylocalhost,native-vmandnetwork, so the script's vocabulary and the real inventory havefully diverged.
This is not in #15127's list because the script is referenced (from the scripts
README.md), sothe unreferenced-script guard never looked at it. Referenced is not the same as working.
Context:
utilities/load-env.shwas a fork of this same job with the same defect and was retired in#15127's first batch. This one is referenced and documented, so it should be corrected rather than
retired — either by mapping the branches onto the three modes that exist, or by generating the
missing files.
Acceptance criteria
missing rather than exporting nothing.
empty.
Refs #15127