Skip to content

fix(shell): strip verbatim UNC prefix for Windows terminal and use dunce canonicalize - #982

Open
heartacker wants to merge 1 commit into
iOfficeAI:mainfrom
heartacker:fix/windows-terminal-path
Open

fix(shell): strip verbatim UNC prefix for Windows terminal and use dunce canonicalize#982
heartacker wants to merge 1 commit into
iOfficeAI:mainfrom
heartacker:fix/windows-terminal-path

Conversation

@heartacker

Copy link
Copy Markdown

Summary

Fixes iOfficeAI/aionrs#270

Problem

On Windows, when clicking 'Open Terminal' for a workspace located on non-system drives (e.g. D:), the system fails with:

指定的路径无效 (The filename, directory name, or volume label syntax is incorrect / path invalid)

Root Cause

  1. std::fs::canonicalize() on Windows prepends the \\?\\Extended-Length/Verbatim prefix (e.g. \\?\\D:\workspace).
  2. Windows cmd.exe does not support the \\?\\Extended-Length syntax. When executing cmd /c start cmd /K pushd "\\?\\D:\...", cmd.exe rejects the \\?\\... prefix with 指定的路径无效. (In contrast, explorer.exe resolves verbatim paths via Shell APIs, which is why 'Open Folder' worked fine).
  3. The rest of the codebase (e.g., in crates/aionui-app/src/services.rs) specifically uses dunce::canonicalize for this exact reason to avoid the \\?\\Extended-Length prefix for Windows CLI compatibility.

Changes

  1. Use dunce::canonicalize in crates/aionui-shell/src/shell.rs for validate_file_exists, validate_path_exists, and validate_directory_exists.
  2. As defense in depth, sanitize \\?\\UNC\\ and \\?\\ prefixes in build_windows_terminal_command.
  3. Add unit test coverage for build_windows_terminal_command verifying verbatim path stripping.

…nce canonicalize

Windows cmd.exe does not support \?\ extended-length verbatim paths
and fails with '指定的路径无效' when running pushd \?\D:\...
Use dunce::canonicalize in path validation so canonical Windows paths
retain standard drive letters without \?\, and sanitize \?\ / \?\UNCin build_windows_terminal_command as defense in depth.

Fixes iOfficeAI/aionrs#270
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(shell): Windows 下跨盘符(如 D 盘)或带特殊字符路径时打开终端失败提示指定的路径无效

1 participant