Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied when using Deno.watchFs() relative path #5742

Closed
epomatti opened this issue May 22, 2020 · 3 comments · Fixed by #5642
Closed

Permission denied when using Deno.watchFs() relative path #5742

epomatti opened this issue May 22, 2020 · 3 comments · Fixed by #5642
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@epomatti
Copy link

epomatti commented May 22, 2020

The following code will fail when running with deno run --allow-read=./src app.ts

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

Error:

error: Uncaught PermissionDenied: read access to "./src", run again with the --allow-read flag
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at new FsWatcher ($deno$/ops/fs_events.ts:15:16)
    at Object.watchFs ($deno$/ops/fs_events.ts:38:10)
    at file:///home/pomatti/projects/dumb-deno/app.ts:1:22

However if i change the first line of the script to use an absolute path it works fine:

const watcher = Deno.watchFs("/home/pomatti/projects/dumb-deno/src");

I guess Deno.watchFs() must allow relative paths when --allow-read is informed on startup?

@zhanyuzhang
Copy link

Maybe you should use deno run -A to try it again ? Because it's possible needing other permission.

@epomatti
Copy link
Author

@zhanyuzhang if I put the absolute path it works, and also the initial error message says "read access". It is something to do with the fact that I specifying the path in --allow-read.

@bartlomieju
Copy link
Member

Paths should be resolved relative to CWD when creating new watcher. Looks like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
3 participants