deno-dotenv icon indicating copy to clipboard operation
deno-dotenv copied to clipboard

When setting safe env access is required

Open oscartbeaumont opened this issue 3 years ago • 0 comments

If you try and run the code the following code with the command deno run --allow-read test.ts it succeeds.

import { config } from "https://deno.land/x/dotenv/mod.ts";

console.log(config());

However, if you use the same command but run the following code it crashes with the error also included below.

import { config } from "https://deno.land/x/dotenv/mod.ts";

console.log(config({ safe: true }));
error: Uncaught PermissionDenied: Requires env access to all, run again with the --allow-env flag
    at Object.opSync (deno:core/01_core.js:149:12)
    at Object.toObject (deno:runtime/js/30_os.js:81:19)
    at assertSafe (https://deno.land/x/[email protected]/mod.ts:174:31)
    at processConfig (https://deno.land/x/[email protected]/mod.ts:114:5)
    at config (https://deno.land/x/[email protected]/mod.ts:63:10)
    at file:///[REDACTED]/test.ts:3:13

I don't understand why the inclusion of the safe parameter would require environment variable access. I am building a small webserver and would prefer to only load environment variables from disk and not allow direct environment variable access to Deno.

Thanks for this awesome module!

oscartbeaumont avatar Feb 12 '22 18:02 oscartbeaumont