workers-sdk
workers-sdk copied to clipboard
🐛 BUG: .env file missing error when none exists and WRANGLER_LOG="debug"
Which Cloudflare product(s) does this pertain to?
Wrangler
What version(s) of the tool(s) are you using?
3.81.0
What version of Node are you using?
22
What operating system and version are you using?
Mac Sonoma 14.6
Describe the Bug
If I set export WRANGLER_LOG=debug and then deploy a Worker, and there is no .env file in the cwd, I get this error in my logs:
> export WRANGLER_LOG=debug
> npx wrangler@latest deploy
🪵 Writing logs to "/Users/brendan/.wrangler/logs/wrangler-2024-10-21_15-25-39_001.log"
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
at Object.openSync (node:fs:573:18)
at Object.readFileSync (node:fs:452:35)
at tryLoadDotEnv (/Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:163894:72)
at loadDotEnv (/Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:163903:12)
at /Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:214085:20
at /Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:179349:16
at maybeAsyncResult (/Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:177570:44)
at /Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:179348:14
at /Users/brendan/.npm/_npx/d77349f55c2be1c0/node_modules/wrangler/wrangler-dist/cli.js:177557:22
at Array.reduce (<anonymous>) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '.env'
}
This is misleading since it's not actually a problem, we are just trying to load .env and swallowing the error (except when you turn on WRANGLER_LOG=debug.
Even when debug logs are on, this seems like an expected scenario not something that should error with a stacktrace?
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
No response