-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: handle non-file URI schemes in runTerminalCommand for WSL2 #9325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: handle non-file URI schemes in runTerminalCommand for WSL2 #9325
Conversation
The fileURLToPath function can throw "The URL must be of scheme file" in some WSL2/remote environments with malformed URIs. Wrap in try-catch to fall through to HOME directory fallback. Fixes continuedev#8091 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
Parse vscode-remote://wsl+distro/path URIs to extract the actual workspace path instead of falling back to Windows HOME directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="core/tools/implementations/runTerminalCommand.ts">
<violation number="1" location="core/tools/implementations/runTerminalCommand.ts:58">
P2: The `url.pathname` returns URL-encoded strings (e.g., `/home/user/my%20project` instead of `/home/user/my project`). Workspace paths containing spaces or special characters will fail because the encoded path doesn't exist on the filesystem. Use `decodeURIComponent(url.pathname)` to match the decoding behavior of `fileURLToPath()` used for file:// URIs.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
Paths with spaces or special characters (e.g., /home/user/my%20project) need decodeURIComponent() to match actual filesystem paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Tests cover: - Basic WSL URI parsing - URL-encoded spaces and special characters - Unicode path handling - Different WSL distro names - Priority of WSL URIs over file:// URIs - Fallback behavior - Edge cases (plus signs, percent signs, mixed encoding) - Comparison with fileURLToPath behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="core/tools/implementations/resolveWorkingDirectory.vitest.ts">
<violation number="1" location="core/tools/implementations/resolveWorkingDirectory.vitest.ts:133">
P2: Environment variable modification should use `afterEach` or `try/finally` to ensure cleanup runs even if assertions fail. If this test fails, `process.env.HOME` remains set to `/test/home`, potentially causing flaky behavior in subsequent tests.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
Ensures process.env.HOME is restored even if assertions fail, preventing flaky behavior in subsequent tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Documents workarounds for: - Building VSIX from WSL2 (extension host selection) - File count issues affecting activation - Terminal command working directory resolution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
d88cbc5 to
6b30a88
Compare
|
Before & after for reference. (With PR #9314 fix.) (gpt-oss-20b) |


Problem
When running
run_terminal_commandin WSL2, it crashes with:Root Cause
The
resolveWorkingDirectoryfunction inrunTerminalCommand.tscallsfileURLToPath()on workspace URIs. In WSL2/remote environments,getWorkspaceDirs()can return URIs likevscode-remote://wsl+Ubuntu/pathinstead offile:///path. ThefileURLToPathfunction throws when the scheme isn'tfile://.Fix
Wrap the
fileURLToPathcall in a try-catch so it falls through to the existing HOME directory fallback instead of crashing. This is a minimal, defensive change - 5 lines added.Fixes #8091
Test plan
🤖 Generated with Claude Code
Summary by cubic
Fixes a crash in runTerminalCommand on WSL2 by resolving vscode-remote://wsl URIs to local paths and safely handling non-file workspace URIs. Falls back to HOME when resolution fails.
Written for commit 6b30a88. Summary will update automatically on new commits.