Version: Deno 2.4.4
OS: Windows 11 Pro
Steps
- Create a
src/index.ts file and DO NOT create .env.missing
- Run
deno compile --allow-net --allow-env --env-file=.env.missing --output=./dist/app src/index.ts
Expected
Successfully build a binary
Actual
Task build deno compile --allow-net --allow-env --env-file=.env.missing --output=./dist/app src/index.ts
Warning The `--env-file` flag was used, but the environment file specified '.env.missing' was not found.
Compile file:///C:/Users/jon/projects/example/src/index.ts to ./dist/app.exe
Warning Environment variables from the file ".env.missing" were embedded in the generated executable file
error: Writing deno compile executable to temporary file './dist\app.exe.tmp-4f6be2f87253cac0'
Caused by:
0: path not found
1: path not found
Workarounds
If I go ahead and create the .env.missing file, then deno compile works fine.
Context
I was looking for a way to do dotenv style env file inheritance (based on development/production) and noticed the following worked fine with deno run but not deno compile:
// ✅ Success
deno run --allow-net --allow-env --env-file=.env --env-file=.env.development --env-file=.env.development.local --watch src/index.ts
// ❌ Failure
deno compile --allow-net --allow-env --env-file=.env --env-file=.env.production --env-file=.env.production.local --output=./dist/app src/index.ts
Usually I use .env, .env.development and .env.production as defaults that are committed into the repo, and then rely on .env.*.local files at dev-time or build-time, to layer in any further values. At run-time, local ENVs would still be expected to override/set any values. This all appears to work as expected except for the failure to build when an --env-file is not found.
Version: Deno 2.4.4
OS: Windows 11 Pro
Steps
src/index.tsfile and DO NOT create.env.missingdeno compile --allow-net --allow-env --env-file=.env.missing --output=./dist/app src/index.tsExpected
Successfully build a binary
Actual
Workarounds
If I go ahead and create the
.env.missingfile, thendeno compileworks fine.Context
I was looking for a way to do
dotenvstyle env file inheritance (based on development/production) and noticed the following worked fine withdeno runbut notdeno compile:Usually I use
.env,.env.developmentand.env.productionas defaults that are committed into the repo, and then rely on.env.*.localfiles at dev-time or build-time, to layer in any further values. At run-time, local ENVs would still be expected to override/set any values. This all appears to work as expected except for the failure to build when an--env-fileis not found.