Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deno: How to allow read permission for directory/folder

Tags:

deno

Looking at https://deno.land/manual/examples/file_system_events which is the code below.

const watcher = Deno.watchFs("./src");
for await (const event of watcher) {
  console.log(">>>> event", event);
  // { kind: "create", paths: [ "/foo.txt" ] }
}

However, when I try to --allow-read permissions I get the error: Is a directory

deno run --allow-read src/  main.ts
error: Is a directory (os error 21)

How do I ensure that the explicit permission --allow-read is permitted for the specified /src folder?

I know that I can use -A to --allow-all, however, I want to be explicit to the allowed permission.

like image 339
Denis Tsoi Avatar asked Nov 22 '25 15:11

Denis Tsoi


1 Answers

I guess I found the problem. Well first of all you need to use a = to add the allowed paths, like so:

deno run --allow-read=src/ main.ts

But it'll still won't work and it seems to be a bug/enhancement.

On your script you need to provide the absolute path and then it will be effective:

const watcher = Deno.watchFs("<ABSOLUTE_PATH>/src");

For me it's an issue on the Deno.watchFs() method and I opened up one on Github:

https://github.com/denoland/deno/issues/5742

like image 176
Evandro Pomatti Avatar answered Nov 24 '25 23:11

Evandro Pomatti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!