Pengling
Pengling
DDeno
Created by Pengling on 2/17/2025 in #help
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"
}
6 replies