[Bug] File links use incorrect URI format in WSL + VS Code Remote
Bug Description
Claude Code Bug Report: File Links Don't Work in WSL + VS Code Remote
Summary
File links generated by Claude Code's Read/Edit tool results use file:/// URIs which fail to open when clicked in a WSL environment accessed via VS Code Remote.
Environment
- OS: Windows 11 with WSL2 (Ubuntu)
- IDE: VS Code Insiders 1.108.2 (running on Windows, connected to WSL via Remote - WSL extension)
- Claude Code Version: 2.1.29
- Claude Code Location:
panel(viaclaudeCode.preferredLocationsetting) - Node: Linux native via nvm (not Windows node)
- Installation Method: npm global install in WSL
Steps to Reproduce
- Open VS Code Insiders on Windows
- Connect to WSL using the Remote - WSL extension
- Open an integrated terminal in VS Code (which runs in WSL)
- Run Claude Code in the terminal
- Ask Claude to edit any file (e.g., "update dummy.json")
- Observe the file link in the output (hover shows
file:///home/username/path/to/file) - Ctrl+click the link
Expected Behavior
The file should open in VS Code's editor pane.
Actual Behavior
A Windows error dialog appears:
- Title: "Visual Studio Code - Insiders"
- Message: "An error occurred opening an external program"
- Details: "Failed to open: The system cannot find the file specified. (0x2)"
Root Cause Analysis
Claude Code generates terminal hyperlinks with file:/// URIs pointing to Linux paths:
file:///home/aircraft/create/ThinAir/projects/vision-ast/va.monorepo.v2/dummy.json
When VS Code on Windows receives this link:
- It recognizes it as a
file://protocol - It attempts to resolve
/home/aircraft/...as a Windows path - Windows cannot find this path (it's a Linux path)
- Error 0x2 (ERROR_FILE_NOT_FOUND) is returned
Correct URI Format for WSL
For files in WSL accessed via VS Code Remote, the URI should be:
vscode-remote://wsl+Ubuntu/home/aircraft/create/ThinAir/projects/vision-ast/va.monorepo.v2/dummy.json
Or alternatively, the UNC path format:
\\wsl$\Ubuntu\home\aircraft\create\ThinAir\projects\vision-ast\va.monorepo.v2\dummy.json
Detection Logic Suggestion
Claude Code could detect WSL + VS Code Remote by checking:
- WSL Detection:
- Check for
/proc/versioncontaining "microsoft" or "WSL" - Check for
WSL_DISTRO_NAMEenvironment variable
- VS Code Remote Detection:
- Check for
VSCODE_IPC_HOOK_CLIenvironment variable - Check for
TERM_PROGRAM=vscode - The IDE connection info in
~/.claude/ide/showsideName: "Visual Studio Code"
- Get WSL Distro Name:
$WSL_DISTRO_NAMEenvironment variable (e.g., "Ubuntu")
When all conditions are met, generate links as:
vscode-remote://wsl+${WSL_DISTRO_NAME}${absolutePath}
Environment Variables Available for Detection
# WSL-specific
WSL_DISTRO_NAME=Ubuntu
WSL_INTEROP=/run/WSL/8_interop
# VS Code-specific
TERM_PROGRAM=vscode
VSCODE_IPC_HOOK_CLI=/run/user/1000/vscode-ipc-...
Workarounds Attempted (None Successful)
- Creating symlink for
codecommand - Doesn't affect link generation - Checking VS Code settings - No relevant terminal link settings
- Checking Claude Code config - No URI format configuration available
Comparison: Working vs Non-Working Links
Working (regular terminal output, e.g., from echo):
- Plain text file paths are detected by VS Code's built-in terminal link provider
- VS Code knows it's in a WSL context and handles the path correctly
Not Working (Claude Code tool output):
- Claude Code generates OSC 8 hyperlinks with explicit
file://URIs - The explicit URI bypasses VS Code's path translation logic
- Windows receives the raw Linux path and fails
Additional Context
- This issue likely affects all WSL users running Claude Code through VS Code Remote
- The issue may also affect other remote development scenarios (SSH, containers)
- Regular terminal file path detection works correctly - only Claude Code's explicit links fail
Files Referenced
- Claude Code IDE connection:
~/.claude/ide/(shows VS Code connection details) - VS Code settings:
/mnt/c/Users/danie/AppData/Roaming/Code - Insiders/User/settings.json
Suggested Fix Priority
High - This breaks a core UX feature (click-to-open files) for all WSL users, which is a significant portion of the Windows developer user base.
Environment Info
- Platform: linux
- Terminal: vscode
- Version: 2.1.29
- Feedback ID: a7352649-7065-4fb8-8673-8ddeeaa227a7
Errors
[{"error":"McpError: MCP error -32000: Connection closed\n at fromError (/$bunfs/root/claude:792:15268)\n at _onclose (/$bunfs/root/claude:792:21728)\n at <anonymous> (/$bunfs/root/claude:792:21042)\n at onCloseHandler (/$bunfs/root/claude:3216:2618)\n at emit (node:events:101:22)\n at <an…
Note: Content was truncated.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗