deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

@std/fs/exists returns true when a path is inaccessible.

Open dsissitka opened this issue 9 months ago • 2 comments

Describe the bug

@std/fs/exists returns true when a path is inaccessible.

Steps to Reproduce

$ ls /root
ls: cannot open directory '/root': Permission denied
$ cat test.ts
import { exists } from "jsr:@std/fs@^1.0.15";

console.log(await exists("/root/foo"))
$ deno run --allow-read test.ts
true
$

Expected behavior

Throw an error. Maybe a Deno.errors.PermissionDenied like Deno.readDir("/root")?

Environment

  • OS: Fedora 41
  • deno version: 2.2.6
  • std version: 1.0.15

dsissitka avatar Mar 29 '25 02:03 dsissitka

exists has an option isReadable, does that cover your use case?

import { exists } from "jsr:@std/fs@^1.0.15";
console.log(await exists("/root/foo", { isReadable: true }));

WWRS avatar Mar 29 '25 13:03 WWRS

this error is also reproducible in NodeJS

0hmX avatar Apr 21 '25 17:04 0hmX