tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.36k stars 2.58k forks source link

[bug] Sidecars file write operation are denied in Windows #11765

Closed mohammadmansour200 closed 15 hours ago

mohammadmansour200 commented 16 hours ago

Describe the bug

In my case i'm using ffmpeg as sidecar, when it tries writing the output file it returns permission denied error, and I assume the solution to that is running this sidecar by itself as an administrator not the whole app, because I tried this and didn't work, what worked was running the terminal as administrator.

Reproduction

Just use any cli program that makes a file write operation, for example use ffmpeg:

./ffmpeg.exe -i input.mp4 output.mp3

ffmpeg returns: output.mp3: Permission denied but in case you run terminal as an administrator it works like a charm.

Expected behavior

Want the sidecar running as administrator and not get this permission error.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 130.0.2849.80
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.14.0
    - npm: 10.7.0

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.0
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.2
    - tauri-plugin-dialog 🦀: 2.0.3
    - @tauri-apps/plugin-dialog : 2.0.1
    - tauri-plugin-updater 🦀: 2.0.2
    - @tauri-apps/plugin-updater : 2.0.0
    - tauri-plugin-process 🦀: 2.0.1
    - @tauri-apps/plugin-process : 2.0.0
    - tauri-plugin-notification 🦀: 2.0.1
    - @tauri-apps/plugin-notification : 2.0.0
    - tauri-plugin-os 🦀: 2.0.1
    - @tauri-apps/plugin-os : 2.0.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Rollup

Stack trace

No response

Additional context

No response

FabianLars commented 15 hours ago

I assume this happens after you installed the app via .msi ? This is expected because Program Files is read-only. That's why we always recommend to write into userdata folders, for example using any of the appXDir paths (these are specific to your app by appending the app identifier).

mohammadmansour200 commented 13 hours ago

I assume this happens after you installed the app via .msi ?

Yes, I did.

This is expected because Program Files is read-only).

I am not writing files in program files, dir. Instead, I am writing it in Temp folder, is it read only too?, what about Video and Audio dirs? What I am doing is first writing to the temp dir, then on success I run copyFile to either videos or audio. But problem is it works on some laptops, and some don't!

FabianLars commented 13 hours ago

hmm the temp dir should generally be writable 🤔 https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a

mohammadmansour200 commented 13 hours ago

hmm the temp dir should generally be writable 🤔 https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a

Weird, maybe there is a different reason I've missed, I think adding modal containing all logs of the sidecar would be very beneficial in this case.

Thanks.