-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
CodeRabbit identified a Windows-specific issue in PR #16: std::fs::canonicalize on Windows produces extended-length UNC paths with \\?\ prefix, which are incompatible with many applications including Node.js.
Problem
In ipc_common.rs:25-27, the code uses:
Ok(abs_path) => {
let path_str = abs_path.to_string_lossy().to_string();On Windows, canonicalize converts paths like C:\Users\... to \\?\C:\Users\.... The frontend "open-file" event handler (which uses Node.js/JavaScript) will receive this broken path string, causing failures on Windows - the primary platform this fix was meant to support.
Solution Options
Option 1: Manual prefix strip (no dependencies)
Ok(abs_path) => {
// Strip Windows extended-length prefix so the frontend
// receives a plain path like C:\... instead of \\?\C:\...
let path_str = abs_path.to_string_lossy()
.strip_prefix(r"\\?\")
.map(str::to_string)
.unwrap_or_else(|| abs_path.to_string_lossy().to_string());Option 2: Use dunce crate (recommended)
Add to Cargo.toml:
dunce = "1"Replace std::fs::canonicalize with dunce::canonicalize:
match dunce::canonicalize(&path) {
Ok(abs_path) => {
let path_str = abs_path.to_string_lossy().to_string();The dunce crate is widely used as a wrapper over std::fs::canonicalize that automatically strips the \\?\ prefix on Windows.
References
- PR fix(tauri): Extract IPC types to shared module for Windows compatibility #16 CodeRabbit review comment (line 27, ipc_common.rs)
- dunce crate
Files Affected
apps/tauri/src-tauri/src/ipc_common.rs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels