Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] path not allowed on the configured scope (on windows) #4130

Closed
RtthLvr opened this issue May 15, 2022 · 15 comments · Fixed by #4188
Closed

[bug] path not allowed on the configured scope (on windows) #4130

RtthLvr opened this issue May 15, 2022 · 15 comments · Fixed by #4188

Comments

@RtthLvr
Copy link

RtthLvr commented May 15, 2022

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": ["**"]
      },
      ...
}
@RtthLvr
Copy link
Author

RtthLvr commented May 16, 2022

more info

error occurs even if select file from tauri dialog, or use rust api to set allow_directory, and allow_file on fs_scope (which is working on macOS, and older version of tauri on Windows)

@nathanbabcock
Copy link

nathanbabcock commented May 18, 2022

I have the same issue with readDir

@nathanbabcock
Copy link

nathanbabcock commented May 18, 2022

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?

@lucasfernog
Copy link
Member

I cannot reproduce this, maybe you can give us a repo we can use to reproduce it @RtthLvr

@RtthLvr
Copy link
Author

RtthLvr commented May 18, 2022

Maybe I have figured my problem out, those files are on my drive that "Windows" doesn't mount on connect, but mounted manually by "Disk Management" (assign drive letter). File permission may be not updated ?

  • that HDD is connected on system startup or anytime, but not mounted yet.
  • on not-working HDD, fs on normal node app can access those files.
  • I tested by changing HDD (that mounted on connect) for testing app contents, and it worked.

this not depends on tauri version (that I mentioned before)
Windows not mount some drives those have macOS formatted EFI partition (not sure why)

@RtthLvr
Copy link
Author

RtthLvr commented May 22, 2022

Maybe I have figured my problem out, those files are on my drive that "Windows" doesn't mount on connect, but mounted manually by "Disk Management" (assign drive letter). File permission may be not updated ?

  • that HDD is connected on system startup or anytime, but not mounted yet.
  • on not-working HDD, fs on normal node app can access those files.
  • I tested by changing HDD (that mounted on connect) for testing app contents, and it worked.

this not depends on tauri version (that I mentioned before)
Windows not mount some drives those have macOS formatted EFI partition (not sure why)

I just really figured out my problem, my disk volume has "Hidden" attribute (even drive letter assigned). Here is output from Windows DISKPART

DISKPART> attributes volume
Read-only              : No
Hidden                 : Yes
No Default Drive Letter: No
Shadow Copy            : No

set attribute "Hidden" to No get it worked.
And thanks for another fixes too.

@Sozialarchiv
Copy link

I have the same issue with an LTO-Tape library. Is there a way to disable the file security?

@Muphet
Copy link

Muphet commented Jan 5, 2023

same issue with latest release. readDir lists all the files but then i want to readtextfile and it throws error

@widersky
Copy link

widersky commented Jan 6, 2023

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.

@hyy110
Copy link

hyy110 commented May 12, 2023

i have the same issue in ubuntu v22.04 TLS

@hyy110
Copy link

hyy110 commented May 12, 2023

"fs": {
"all": true,
"readFile": true,
"writeFile": true,
"readDir": true,
"copyFile": true,
"createDir": true,
"removeDir": true,
"removeFile": true,
"renameFile": true,
"scope": ["*"]
}
it did't work

@FabianLars
Copy link
Member

@hyy110 * only allows one "level" of the filesystem, if you want to allow nested files and folders you'd be looking for **. Disclaimer: We obviously don't recommend using ** in production apps since it allows access to the whole file system which from my experience only very very few apps actually need.

@studiowebux
Copy link

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

@Wanderson-Magalhaes
Copy link

Thanks @studiowebux
This worked for me in Tauri 1.4 to give access to the Windows "AppData/roaming" folder, that way I can record in subfolders that are dynamically created, example:
"$APPDATA/com.my-app/DYNAMIC_FOLDER/"
"$APPDATA/com.my-app/DYNAMIC_FOLDER/all_files"

"fs": {
  "all": true,
  "readFile": true,
  "writeFile": true,
  "readDir": true,
  "copyFile": true,
  "createDir": true,
  "removeDir": true,
  "removeFile": true,
  "renameFile": true,
  "exists": true,
  "scope": [
   "$APPDATA/**",
   "$APPDATA/*",
   "$APPDATA/",
   "$APPDATA"
  ]
}

@YunYouJun
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.