You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.env loading aborts all commands when a .env in the working dir (or any ancestor) uses export-prefixed lines #13291
As of v0.21.x, Dagger auto-loads .env files from the working directory and its ancestors ("inner"/"outer env files"). If any such file uses the extremely common export KEY=value convention, Dagger aborts the command with:
failed to load inner env file in <dir>: parse error: "export FOO=bar": not a bare assignment
(outer env file when the offending file is in an ancestor directory.) The command fails entirely — dagger init,
dagger call, dagger functions, etc. all refuse to run.
An .env in $HOME or a parent project dir (common) breaks every Dagger command run beneath it.
There appears to be no flag or env var to disable env loading (dagger --help shows none), so the only
workaround is editing/removing the unrelated file or dropping a shadowing bare-assignment .env in the working
dir.
Suggested fixes (any one)
Accept and strip a leading export when parsing dotenv lines.
Downgrade unparseable lines/files to a warning instead of a hard error.
Add an opt-out (e.g. --no-env / DAGGER_NO_ENV=1) and/or only load .env from the module/workdir, not arbitrary ancestors.
Workaround (for others hitting this)
Put a .env containing a bare assignment (e.g. DUMMY=dummy) in your working directory; Dagger loads the nearest file and stops walking up.
Dagger version
v0.21.x
Steps to reproduce
Reproduction
mkdir /tmp/dagger-env-repro && cd /tmp/dagger-env-repro
printf 'export FOO=bar\n' > .env
dagger init --sdk=go --name=t --source=.dagger
# => Error: ... parse error: "export FOO=bar": not a bare assignment
Matrix (all else equal):
┌──────────────────┬────────┐
│ .env contents │ Result │
├──────────────────┼────────┤
│ export FOO=bar │ abort │
├──────────────────┼────────┤
│ export FOO="bar" │ abort │
├──────────────────┼────────┤
│ FOO=bar │ ok │
└──────────────────┴────────┘
So the trigger is specifically the export prefix; bare assignments are fine.
Expected
export-prefixed lines are valid in the dotenv files most tools accept (direnv, set -a; . ./.env, many .env
loaders, and shell source). Dagger should either parse export KEY=value (ignoring the export keyword), or
skip/warn on lines it can't parse rather than aborting — especially for ancestor .env files that have nothing to
do with Dagger.
Actual
A single unrelated .env anywhere up the directory tree makes Dagger unusable in that subtree, with no way to
proceed.
Activity