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] 'resolve_resource' does not give the correct path on windows #5096

Closed
zhibisora opened this issue Aug 30, 2022 · 1 comment
Closed
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@zhibisora
Copy link

zhibisora commented Aug 30, 2022

Describe the bug

tauri::Builder::default()
        .setup(move |app| {
            let window = app.get_window("main").unwrap();
            let script_path = app
                .path_resolver()
                .resolve_resource("resources")
                .unwrap()
                .to_string_lossy()
                .to_string();

            print!("{}", script_path);
            // ...

If your project path is 'D:\foo', and your 'resources' path is 'D:\foo\resources'.

// in tauri.conf.json
"resources": [
        "resources"
      ],

Then the 'script_path' you get is

\\?\D:\foo\resources   // all '\' is escaped

It has more '\\?\' than the real path and causes errors in some of my functions.

Reproduction

Use the configuration in the bug description.

Expected behavior

Get

D:\foo\resources

instead of

\\?\D:\foo\resources

Platform and versions

Environment
  › OS: Windows 10.0.19044 X64
  › Webview2: 104.0.1293.70
  › MSVC:
      - Visual Studio ???? 2019
  › Node.js: 16.16.0
  › npm: 8.11.0
  › pnpm: 7.9.0
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.63.0
  › cargo: 1.63.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
  › @tauri-apps/cli [NPM]: 1.0.5@tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.5,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.2,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:8010/
  › framework: Vue.js

App directory structure
  ├─ .vscode
  ├─ dist
  ├─ node_modules
  ├─ public
  ├─ src
  ├─ src-tauri
  └─ test

Stack trace

No response

Additional context

Also, I don't know how to get the output from 'println!()' in setup in the example, you can check the value of script_path by debug.

If anyone knows how to get the output of println in setup please let me know, or discuss it here #5094 (comment).

@zhibisora zhibisora added status: needs triage This issue needs to triage, applied to new issues type: bug labels Aug 30, 2022
@amrbashir
Copy link
Member

This is not a bug, this a general Windows thing called UNC path, Rust just doesn't hide it from you like other languages. You can use dunce crate if you don't want to deal with it directly.

@amrbashir amrbashir closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants