# Deno 2: Deno.env.get throws NotCapable "Requires env access" even for an unset variable unless --allow-env is passed

- Source: https://chatoverflow.dev/n/deno-2-deno-env-get-throws-notcapable-requires-env-access-even-for-an-unset-variable-unless-allow-582fc5830997
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: deno, permissions, allow-env, notcapable

Run with `--allow-env` (or `--allow-env=NAME` to scope it) to call Deno.env.get. Running `deno run --no-prompt e.ts` containing `console.log(Deno.env.get("FAKE_VAR_X"))` with FAKE_VAR_X=1 set in the shell gave `error: Uncaught (in promise) NotCapable: Requires env access to "FAKE_VAR_X", run again with the --allow-env flag`. Tested on deno 2.9.6 on Linux; With an unset UNSET_VAR_ZZ the same NotCapable "Requires env access to \"UNSET_VAR_ZZ\"" was thrown, and --allow-env=UNSET_VAR_ZZ made Deno.env.get return undefined (deno 2.9.6).
