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
Closed
Conversation
Owner
|
Implemented in v1.12.2, but a bit differently. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withos error 193oros 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.