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

PermissionDenied (EACCES code) when trying to reading files from network-mapped drive #24643

Closed
KarolBajkowski opened this issue Jul 18, 2024 · 4 comments
Labels
permissions related to --allow-* flags runtime Relates to code in the runtime crate windows Related to Windows platform

Comments

@KarolBajkowski
Copy link

KarolBajkowski commented Jul 18, 2024

Version: Deno 1.45.2
My environment

> [Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.22631.0 Microsoft Windows NT 10.0.22631.0

Reading files from network-mapped drives doesn't seem to work. For example code
The z: is a network-mapped drive
File Z:\d1\file.txt exists

try {
    console.log(await Deno.readTextFile(String.raw`Z:\d1\file.txt`));
}
catch(e) {
    console.log(e);
    throw e;
}

throws the following error:

PermissionDenied: permission denied: readfile 'Z:\d1\file.txt'
    at Object.readTextFile (ext:deno_fs/30_fs.js:878:24)
    at file:///C:/t1/i.ts:2:28 {
  name: "PermissionDenied",
  code: "EACCES"
}

The script works fine with the local files, the issue emerges only with files on the network mapped drive.

I tried on two different machines (with Windows) (a second machine without antivirus) - on both had the same behaviour.

I did some research and I found the last working version was 1.42.4. On 1.43.0 and on the latest the file read doesn't work. Yeah, I know, that's weird, I couldn't believe that as well. I'm attaching a recording to show you how it behaves on my machine.
For now, the workaround in my case is using the 1.42.4 version but it isn't an ideal solution. I hope my issue description will help to fix that in future versions :)

deno.bug.2024-07-18.185401.mp4

Steps to reproduce (similar to one from attached recording):

# create a file on the network-mapped drive
echo "foo" > 'Z:\file.txt'

# create Deno program:
echo 'try {
    console.log(await Deno.readTextFile(String.raw`Z:\file.txt`));
}
catch(e) {
    console.log(e);
    throw e;
}' > main.ts

# make sure the version is 1.43.0 or above
deno upgrade --version 1.45.2

# execute the program:
deno run --allow-read .\main.ts

the output should be as follows

> deno run --allow-read .\main.ts
PermissionDenied: permission denied: readfile 'Z:\file.txt'
    at Object.readTextFile (ext:deno_fs/30_fs.js:878:24)
    at file:///C:/t1/main.ts:2:28 {
  name: "PermissionDenied",
  code: "EACCES"
}
error: Uncaught (in promise) PermissionDenied: permission denied: readfile 'Z:\file.txt'
    console.log(await Deno.readTextFile(String.raw`Z:\file.txt`));
                           ^
    at Object.readTextFile (ext:deno_fs/30_fs.js:878:24)
    at file:///C:/t1/main.ts:2:28
@lucacasonato lucacasonato added permissions related to --allow-* flags windows Related to Windows platform runtime Relates to code in the runtime crate labels Aug 2, 2024
@yazan-abdalrahman
Copy link
Contributor

@lucacasonato @dsherret @bartlomieju @KarolBajkowski
it was fixed on 1.46

image

@KarolBajkowski
Copy link
Author

Thank you for fixing that! :)
I think my setup is wrong because it requires me to run the program with -allow-all instead of -allow-read. The --allow-read is causing PermissionDenied on my machine. I'm not sure why that happens. But that's not a big deal for me. We can close that issue.
image

@yazan-abdalrahman
Copy link
Contributor

@lucacasonato @dsherret
I think it a duplicate from #24703

@KarolBajkowski
Copy link
Author

@yazan-abdalrahman Yes, the #24703 is reproducible on my machine. I think it's the same issue. I'll close that issue and I'll go to #24703

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
permissions related to --allow-* flags runtime Relates to code in the runtime crate windows Related to Windows platform
Projects
None yet
Development

No branches or pull requests

3 participants