Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing variables via process.env from node:process in deno test without --allow-env permission silently returns undefined #28125

Open
lionel-rowe opened this issue Feb 15, 2025 · 0 comments · May be fixed by #28280

Comments

@lionel-rowe
Copy link
Contributor

Version: Deno 2.1.10

With the following file test.ts:

import process from 'node:process'

console.log(process.env.SOME_ENV_VAR)

deno run without --allow-env permission prompts as expected:

SOME_ENV_VAR=1 deno run test.ts
# ┏ ⚠️  Deno requests env access to "SOME_ENV_VAR".
# ┠─ To see a stack trace for this prompt, set the DENO_TRACE_PERMISSIONS environmental variable.
# ┠─ Learn more at: https://docs.deno.com/go/--allow-env
# ┠─ Run again with --allow-env to bypass this prompt.
# ┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions) > 

However, deno test without --allow-env silently returns undefined (expected to throw error, as deno test doesn't prompt for permissions):

SOME_ENV_VAR=1 deno test test.ts
# Check file:///path/to/test.ts
# ------- pre-test output -------
# undefined
# ----- pre-test output end -----
# running 0 tests from ./test.ts
# 
# ok | 0 passed | 0 failed (2ms)

Conversely, deno testing the equivalent code with Deno.env.get('SOME_ENV_VAR') throws as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant