denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.06k stars 5.14k forks source link

Permission regression with `deno compile` #23715

Closed NeKzor closed 1 week ago

NeKzor commented 1 week ago

Executing a compiled binary from any path that is not the same as the current working directory when invoking deno compile returns a permission error even when the permission flags have been set. This started to happen since Deno 1.42.

Minimal reproducible example:

$ cat main.ts
try { Deno.readTextFileSync('a.txt') }
catch (err) { console.log(err.message); }

$ deno compile --output=bin/a.out --no-prompt --allow-read=a.txt main.ts

Expected output:

$ ./bin/a.out
No such file or directory (os error 2): readfile 'a.txt'

$ cd bin && ./a.out
No such file or directory (os error 2): readfile 'a.txt'

Actual output:

$ ./bin/a.out
No such file or directory (os error 2): readfile 'a.txt'

$ cd bin && ./a.out
Requires read access to "a.txt", run again with the --allow-read flag
NeKzor commented 1 week ago

Found the commit that introduced this bug: 5403e4f06b2bb9da60c67b7c1909f4d412c20307