tauri-apps / tauri

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

[bug] `__TAURI__.os.tempdir()` API regression: broken in windows after latest Tauri update #10285

Closed abose closed 1 month ago

abose commented 1 month ago

Describe the bug

In Windows OS, window.__TAURI__.os.tempdir() API is broken. It returns invalid path:. It is easily reproduicable directly in the browser console. Here is the console output:

> await window.__TAURI__.os.tempdir()
> '\\\\?\\C:\\Users\\home\\AppData\\Local\\Temp'
// its supposed to be something like this below:
> await window.__TAURI__.path.appLocalDataDir()
> 'C:\\Users\\home\\AppData\\Local\\io.phcode.dev\\'

Notice the \\\\?\\ prefix which was not coming in earlier.

Background: We were investigating integ test failures on updating to latest tauri builds in this pr: https://github.com/phcode-dev/phoenix-desktop/pull/461

@tauri-apps/cli 1.5.14 -> 1.6.0 tauri 1.6.8 -> 1.7.1 tauri-build 1.5.2 -> 1.5.3

Reproduction

It is easily reproduicable directly in the browser console. Here is the console output:

> await window.__TAURI__.os.tempdir()
> '\\\\?\\C:\\Users\\home\\AppData\\Local\\Temp'

Expected behavior

The path returned should be of the form: C:\\Users\\home\\AppData\\Local\\Temp

Full tauri info output

PS E:\code\phoenix-desktop> tauri info

[✔] Environment                                              
    - OS: Windows 10.0.19045 X64                             
    ✔ WebView2: 126.0.2592.102                               
    ✔ MSVC:                                                  
        - Visual Studio Build Tools 2019                     
        - Visual Studio Build Tools 2022                     
    ✔ rustc: 1.71.0 (8ede3aae2 2023-07-12)                   
    ✔ cargo: 1.71.0 (cfd3bbd8f 2023-06-08)                   
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)                  
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.9.0                                           
    - npm: 10.2.0                                            

[-] Packages                                                 
    - tauri [RUST]: 1.7.1                                    
    - tauri-build [RUST]: 1.5.3                              
    - wry [RUST]: 0.24.10                                    
    - tao [RUST]: 0.16.7                                     
    - @tauri-apps/api : not installed!                      
    - @tauri-apps/cli [NPM]: 1.5.14 (outdated, latest: 1.6.0)

[-] App                                                      
    - build-type: bundle                                     
    - CSP: unset                                             
    - distDir: ../src/                                       
    - devPath: http://localhost:8000/src/

Stack trace

No response

Additional context

Maybe related to? https://github.com/tauri-apps/tauri/issues/10272

abose commented 1 month ago

NB: The tests are failing in clean builds in github actions as well with latest tauri see: https://github.com/phcode-dev/phoenix-desktop/pull/461

Exact error log line: https://github.com/phcode-dev/phoenix-desktop/actions/runs/9762153481/job/27052280845?pr=461#step:9:1655

FabianLars commented 1 month ago

Caused by https://github.com/tauri-apps/tauri/pull/9588

FabianLars commented 1 month ago

Hmm, technically i guess we could also let this count as a bug fix because most other apis should return paths with the //?/ prefix. I'm really only considering this because i don't like the inconsistency.

@amrbashir What's your opinion? Simply revert this single function? Leave it as is to match the other functions? Add dunce everywhere like in v2 in a patch?

amrbashir commented 1 month ago

let's use dunce on that API only, to revert and fix the breaking behavior. Any consistency changes that requires breaking changes should be made to v2 only.

FabianLars commented 1 month ago

coolio, expected that answer but wanted to double check

datner commented 1 month ago

because most other apis should return paths with the //?/ prefix.

@FabianLars why? is \?C:\a\b\c a valid path on windows? why is that prefix desireable?

EDIT: oh my god

FabianLars commented 1 month ago

Yes it is a valid path. Search for UNC paths to learn more.

That said, it's not really desirable as many tools can't handle them. Tauri's apis return UNC paths because Rust's apis do and since it'd be a breaking change to not return UNC paths (basically this gh issue but the other way around), we can only change it in v2 (and did so)