Skip to content

Fix cargo runner execution error on Windows when workspace path contains spaces (Enhances compatibility with VS Code forks)#1384

Closed
2bitbit wants to merge 1 commit intovadimcn:masterfrom
2bitbit:fix-cargo-runner-space-path
Closed

Fix cargo runner execution error on Windows when workspace path contains spaces (Enhances compatibility with VS Code forks)#1384
2bitbit wants to merge 1 commit intovadimcn:masterfrom
2bitbit:fix-cargo-runner-space-path

Conversation

@2bitbit
Copy link
Copy Markdown

@2bitbit 2bitbit commented Mar 18, 2026

Description:
When using CodeLLDB to debug a Rust project on Windows, if the user's profile path (or extension installation path) contains a space (e.g., C:\Users\Xie bro\...), launching the debugger via the default Cargo task fails with os error 193 or os error 2.

Note: While vanilla VS Code sometimes masks this issue due to its specific internal task argument escaping, this bug consistently triggers fatal crashes in VS Code forks and derivatives (such as Cursor, Antigravity, etc.) when handling paths with spaces.

Root Cause:
In extension/cargo.ts, the cargo runner is currently injected as a raw string:
--config=target.'cfg(all())'.runner='${launcher}'
When Cargo parses this configuration, it splits the unescaped string by spaces. This causes Windows to incorrectly interpret the first half of the path as the executable (e.g., trying to run C:\Users\Xie) and the rest of the path as arguments, immediately crashing the launch process.

Solution:
Changed the injected runner configuration to use the standard TOML array format and replaced backslashes with forward slashes to prevent any escape sequence corruption during CLI handoffs:
--config=target.'cfg(all())'.runner=["${launcher.replace(/\\/g, '/')}"]

By passing the path as a TOML array ["..."], Cargo strictly interprets the entire path as a single executable, regardless of spaces. Tested locally and this perfectly resolves the startup crash, ensuring robust compatibility across all VS Code-based IDEs.

@vadimcn vadimcn added this to the v1.12.2 milestone Apr 21, 2026
@vadimcn
Copy link
Copy Markdown
Owner

vadimcn commented Apr 21, 2026

Implemented in v1.12.2, but a bit differently.

@vadimcn vadimcn closed this Apr 21, 2026
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.

2 participants