Skip to content

Conversation

@shanevcantwell
Copy link

@shanevcantwell shanevcantwell commented Dec 26, 2025

Problem

When running run_terminal_command in WSL2, it crashes with:

run_terminal_command failed with the message: The URL must be of scheme file

Root Cause

The resolveWorkingDirectory function in runTerminalCommand.ts calls fileURLToPath() on workspace URIs. In WSL2/remote environments, getWorkspaceDirs() can return URIs like vscode-remote://wsl+Ubuntu/path instead of file:///path. The fileURLToPath function throws when the scheme isn't file://.

Fix

Wrap the fileURLToPath call 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

  • Tested locally in WSL2 environment where this was previously failing
  • Verified terminal commands execute successfully after fix

🤖 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.

  • Bug Fixes
    • Parse vscode-remote://wsl+distro/path URIs and decode the pathname to extract the workspace path.
    • Wrap fileURLToPath in try/catch; fall back to HOME when URI parsing fails.

Written for commit 6b30a88. Summary will update automatically on new commits.

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]>
@shanevcantwell shanevcantwell requested a review from a team as a code owner December 26, 2025 12:06
@shanevcantwell shanevcantwell requested review from RomneyDa and removed request for a team December 26, 2025 12:06
@continue
Copy link
Contributor

continue bot commented Dec 26, 2025

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts


Unsubscribe from All Green comments

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 26, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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]>
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Dec 26, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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&#39;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.

shanevcantwell and others added 2 commits December 26, 2025 05:14
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]>
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Dec 26, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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]>
shanevcantwell and others added 2 commits December 26, 2025 06:22
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]>
@shanevcantwell shanevcantwell force-pushed the fix/wsl2-terminal-command-uri branch from d88cbc5 to 6b30a88 Compare December 26, 2025 13:27
@shanevcantwell
Copy link
Author

shanevcantwell commented Dec 26, 2025

Before & after for reference. (With PR #9314 fix.) (gpt-oss-20b)
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Bug: Cannot run commands in terminal "The URL must be of scheme file"

1 participant