Skip to content

readDir on a directory containing a broken symlink fails with a confusing error #2014

@krisajenkins

Description

@krisajenkins

Current Behaviour
I am calling readDir on ~/Documents. That directory happens to contain a broken symlink. The call to readDir fails with this error:

Error: failed to read directory at path: /Users/me/Documents with error: No such file or directory (os error 2)

This is untrue. The directory definitely exists. Digging into the source, I believe I've found the problem. It arises on this line when the code is attempting to read the symlink's metadata. Since the symlink is invalid, the code throws an error, which is then incorrectly reported here as being a problem with the directory.

Expected Behaviour

The code should not throw an error. It should be possible to read directories that contain invalid symlinks. Reading the symlink should fail, but reading its parent should not.

At the very least, the error message should reference the problematic file, not the parent directory.

tauri info


[✔] Environment
    - OS: Mac OS 15.1.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (1980-01-01)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 22.2.0
    - yarn: 1.22.22
    - npm: 10.7.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.5
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.2
    - tauri-plugin-log 🦀: 2.0.1
    - @tauri-apps/plugin-log : 2.0.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1234/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions