Skip to content

Conversation

@shanevcantwell
Copy link
Contributor

@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 and other remote environments by resolving vscode-remote URIs to working paths and safely handling non-file workspace URIs. Falls back to HOME when resolution fails.

  • Bug Fixes
    • Generalize remote URI support: parse vscode-remote schemes (WSL, SSH, dev-container) and decode the pathname.
    • Prefer file:// workspaces and wrap fileURLToPath in try/catch; fall back to HOME when URI parsing fails.

Written for commit 8e5a7c2. Summary will update on new commits.


Continue Tasks

Status Task Actions
✅ Merged Update docs on PR PR · View
▶️ Queued Optimize Website Performance View

Powered by Continue

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 <noreply@anthropic.com>
@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 <noreply@anthropic.com>
@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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@shanevcantwell shanevcantwell force-pushed the fix/wsl2-terminal-command-uri branch from d88cbc5 to 6b30a88 Compare December 26, 2025 13:27
@shanevcantwell
Copy link
Contributor Author

shanevcantwell commented Dec 26, 2025

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

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shanevcantwell Thanks for the contribution! The only blocking change is the CLAUDE.md note

function resolveWorkingDirectory(workspaceDirs: string[]): string {
// Handle vscode-remote://wsl+distro/path URIs (WSL2 remote workspaces)
const wslWorkspaceDir = workspaceDirs.find((dir) =>
dir.startsWith("vscode-remote://wsl"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we could write this that isn't so specific to vscode-remote://wsl? I suppose the same issue applies to any non-file URIs? If not obvious this is fine for now but it feels a bit specific

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that was overly narrow. I'll re-submit with it more widely applicable.

CLAUDE.md Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use AGENTS.md instead of CLAUDE.md, if any updates are need to AGENTS.md could you make them there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that was an oversight to be included at all. Removed.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Jan 6, 2026
- Remove WSL-specific check in favor of generic URI handling
- Support all vscode-remote:// URI schemes (WSL, SSH, dev-container)
- Prefer file:// URIs when available, fall back to remote URIs
- Add tests for various remote URI formats
- Remove CLAUDE.md per reviewer feedback (use AGENTS.md convention)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 14, 2026
Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@RomneyDa RomneyDa merged commit e419333 into continuedev:main Jan 14, 2026
57 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Jan 14, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2026
@sestinj
Copy link
Contributor

sestinj commented Jan 15, 2026

🎉 This PR is included in version 1.39.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

lgtm This PR has been approved by a maintainer released size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

3 participants