tauri: [bug] path not allowed on the configured scope (on windows)

Describe the bug

on Windows, path not allowed on the configured scope: D:\path_to_file occurs when executing any fs api on files those aren’t in any $… variables even scope is [“**”]

Reproduction

  1. tested on latest version of tauri on macOS, and success (no error)
  2. tested on latest version of tauri on Windows, error occured

Expected behavior

none of the error should be occured

Platform and versions

Environment
  › OS: Windows 10.0.22000 X64
  › Webview2: 101.0.1210.39
  › MSVC:
      - Visual Studio Build Tools 2019
  › Node.js: 17.3.0
  › npm: 8.3.0
  › pnpm: Not installed!
  › yarn: 1.22.18
  › rustup: 1.24.3
  › rustc: 1.60.0
  › cargo: 1.60.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.10
  › @tauri-apps/api [NPM]: 1.0.0-rc.5
  › tauri [RUST]: 1.0.0-rc.10,
  › tauri-build [RUST]: 1.0.0-rc.8,
  › tao [RUST]: 0.8.4,
  › wry [RUST]: 0.16.2,

App
  › build-type: bundle
  › CSP:
  › distDir: Set automatically by Vue CLI plugin
  › devPath: Set automatically by Vue CLI plugin
  › framework: Vue.js (Vue CLI)
  › bundler: Webpack

App directory structure
  ├─ node_modules
  ├─ public
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

  • on path.appDir() works fine but on other paths (those aren’t in any $… variables), not working even scope is [“**”]
  • on macOS with latest version of tauri and the same configs, this error doesn’t occur
  • all relevant functions on those actions in the app are unchanged

tauri config :

"allowlist": {
      "all": true,
      "fs": {
        "scope": ["**"]
      },
      ...
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I use scope: ["*/**"] and it works.

If it helps someone:

"fs": {
        "readFile": true,
        "writeFile": true,
        "readDir": true,
        "createDir": true,
        "exists": true,
        "scope": ["$DOCUMENT/**", "$DOCUMENT/*", "$DOCUMENT"]
      }

It gives access to everything in the document directory

I can read the directory, save new file, open files

Had the same problem, but I think I’ve fixed it!

You need to add to the “scope” EVERY SINGLE FOLDER you use, for example:

"scope": [
    "$HOME/.your-app-data/*",
    "$HOME/.your-app-data",
    "$HOME/*"
]

AFAIK the order here counts so you need to move from the deepest nesting up.

I tried again today and now I am using readDir in combination with "scope": ["**"] and I’m not getting the error anymore.

I’m not sure the root cause. I think it might be something to do with openFile (which is supposed to provide fs permissions to paths that are opened – I am using that in my app). I’ll post again if I’m able to reproduce the error again.

@RtthLvr are you still seeing it on your end?