Denis Tsoi
Denis Tsoi

Reputation: 10414

Deno: How to allow read permission for directory/folder

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.

Upvotes: 3

Views: 1244

Answers (1)

Evandro Pomatti
Evandro Pomatti

Reputation: 15134

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

Upvotes: 2

Related Questions