Pengling
Pengling5d ago

Cannot copy files from `AppData/Local/` despite --allow-all flag

Description When attempting to copy a file from AppData/Local/ using @std/fs in Deno, the operation fails with a PermissionDenied (os error 5). This occurs even when running Deno with the --allow-all flag. Code Sample
import { copy } from "@std/fs";

const path = `C:/Users/USER/AppData/Local/deno/latest.txt`;
const target = `S:/foo/`;

const CopyOptions = { overwrite: true, preserveTimestamps: false };

try {
await copy(path, target, CopyOptions);
} catch (error) {
console.error(error);
}
import { copy } from "@std/fs";

const path = `C:/Users/USER/AppData/Local/deno/latest.txt`;
const target = `S:/foo/`;

const CopyOptions = { overwrite: true, preserveTimestamps: false };

try {
await copy(path, target, CopyOptions);
} catch (error) {
console.error(error);
}
deno run --allow-all sample.ts
deno run --allow-all sample.ts
Error
PermissionDenied: Access is denied. (os error 5): copy 'C:\Users\USER\AppData\Local\deno\latest.txt' -> 'S:\foo\'
at async Object.copyFile (ext:deno_fs/30_fs.js:145:3)
at async copyFile (https://jsr.io/@std/fs/1.0.13/copy.ts:108:3)
at async copy (https://jsr.io/@std/fs/1.0.13/copy.ts:333:5)
name: "PermissionDenied",
code: "EPERM"
}
PermissionDenied: Access is denied. (os error 5): copy 'C:\Users\USER\AppData\Local\deno\latest.txt' -> 'S:\foo\'
at async Object.copyFile (ext:deno_fs/30_fs.js:145:3)
at async copyFile (https://jsr.io/@std/fs/1.0.13/copy.ts:108:3)
at async copy (https://jsr.io/@std/fs/1.0.13/copy.ts:333:5)
name: "PermissionDenied",
code: "EPERM"
}
3 Replies
kt3k
kt3k4d ago
PermissionDenied is thrown when the operation is denied by OS, not Deno. Does your user account have appropriate access to both source and target? Note: If the operation is denied by Deno's permission system, then NotCapable error is thrown
Pengling
PenglingOP2d ago
I have do have all perms, infact using Deno.Command copied the files without any issue so not sure what's going on
No description
Pengling
PenglingOP2d ago
tho the files that i tried to copy did have the readonly flag, but C:/Users/USER/AppData/Local/deno/latest.txt didn't so i dont think that could be the issue
No description

Did you find this page helpful?