tauri-apps / tauri

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

[bug] shell.open() doesn't work with file paths with spaces on Windows 10 #6431

Open Keilo75 opened 1 year ago

Keilo75 commented 1 year ago

Describe the bug

When using the shell.open javascript API, folders are not correctly opened on Windows 10 if they have spaces in the path. Depending on the formatting of the path, several things may happen, as shown in the screenshot below: image

The command line window looks like this: image The error dialog looks like this (apologies for the German, basically says that 'Files' cannot be found): image The console displays the following error message upon closing the dialog:

Uncaught (in promise) shell error: failed to open: Scoped shell IO error: Launcher "cmd" "/c" "start" "\"C:\\Program Files (x86)\"" failed with ExitStatus(ExitStatus(1))

No file explorer is ever opened though.

Reproduction

This repository demonstrates the bug: https://github.com/Keilo75/shell-open-bug-mre

  1. Clone it
  2. npm install
  3. npm run tauri dev
  4. Click on the buttons and open the developer console to see the bug

Expected behavior

The file explorer opens with the given path, as described in https://tauri.app/v1/api/js/shell/.

Platform and versions

Environment
  › OS: Windows 10.0.19045 X64
  › Webview2: 110.0.1587.69
  › MSVC: 
      - Visual Studio Community 2022
      - Visual Studio Build Tools 2022
  › Node.js: 16.17.1
  › npm: 8.15.0
  › pnpm: 7.17.1
  › yarn: 1.22.10
  › rustup: 1.25.1
  › rustc: 1.65.0
  › cargo: 1.65.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
  › @tauri-apps/cli [NPM]: 1.2.3
  › @tauri-apps/api [NPM]: 1.2.0
  › tauri [RUST]: 1.2.4,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.8,
  › wry [RUST]: 0.23.4,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/
  › bundler: Vite

App directory structure
  ├─ .git
  ├─ .vscode
  ├─ node_modules
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

No response

melMass commented 1 year ago

That's the expected behaviour. Shell open with a folder would open a shell at that path most of the time. Depending on the platform you must use explorer (win), open (mac), xdg_open and variant on linux.

There is a crate that wraps it for you: opener

amrbashir commented 1 year ago

Should be fixed once https://github.com/tauri-apps/tauri/pull/6441 is merged