Repository navigation
Description
VS Code Remote-SSH File Tool Path Resolution Bug
Issue Summary
GitHub Copilot Agent file editing tools fail completely in Remote-SSH workspace. Tools report success but files are never created on the remote filesystem. The workspace path is registered as \\opt\\apps\\dealer (with backslashes) instead of proper remote URI scheme, causing all file operations to be silently dropped.
Environment
Local System:
- OS: Windows
- VS Code Version:
- Version: 1.107.0 (user setup)
- Commit: 618725e
- Date: 2025-12-10T07:43:47.883Z
- Electron: 39.2.3
- ElectronBuildId: 12895514
- Chromium: 142.0.7444.175
- Node.js: 22.21.1
- V8: 14.2.231.21-electron.0
- OS: Windows_NT x64 10.0.22631
- Remote-SSH Extension Version: 0.122.0
Remote System:
- OS: Linux
- Connection: SSH
- Workspace Path (actual):
/opt/apps/dealer - Workspace Path (VS Code shows):
\opt\apps\dealer(backslashes)
Extensions:
- GitHub Copilot: Running on UI (required for Chat to function)
- GitHub Copilot Chat: Running on UI
- Remote-SSH: Installed
Problem Description
Symptoms
- All file read/write operations fail with error:
"File \\opt\apps\dealer\[filename] is outside of the workspace" - File creation reports false success - tools report "Successfully edited" but files don't exist on filesystem
- User must approve each operation - VS Code prompts "Allow edits to sensitive files? The model wants to edit files outside of your workspace"
- Search tools work -
file_searchandgrep_searchsuccessfully locate files - Terminal commands work -
run_in_terminalwith/opt/apps/dealer/paths works perfectly
Evidence
1. File Search Works
file_search("*.md")
Results:
\\opt\\apps\\dealer\\README.md ✓
\\opt\\apps\\dealer\\Code_Quality_Guide.md ✓
2. File Read Fails
read_file("\\opt\\apps\\dealer\\README.md", startLine=1, endLine=10)
Error: "File \\opt\apps\dealer\README.md is outside of the workspace, and not open in an editor, and can't be read"
3. File Creation False Success
create_file("\\opt\\apps\\dealer\\.local\\test_write.txt", content="test")
Response: "The following files were successfully edited: \\opt\apps\dealer\.local\test_write.txt"
Terminal verification:
$ ls -la /opt/apps/dealer/.local/test_write.txt
ls: cannot access '/opt/apps/dealer/.local/test_write.txt': No such file or directory
4. Terminal Works
run_in_terminal("cat /opt/apps/dealer/README.md")
Result: Successfully returns file contents ✓
run_in_terminal("echo 'test' > /opt/apps/dealer/.local/terminal_test.txt")
Result: File created successfully ✓
5. Grep Search Works
grep_search(query="Dealer", includePattern="README.md")
Result: 1 match
<match path="\\opt\\apps\\dealer\\README.md" line=1>
Root Cause Analysis
The workspace is being registered with an incorrect path format:
- Expected:
vscode-remote://ssh-remote+hostname/opt/apps/dealer/(proper remote URI) - Actual:
\opt\apps\dealer(backslashes, no URI scheme)
This malformed path causes:
- File tools cannot resolve paths to actual filesystem locations
- VS Code treats all file operations as "outside workspace" (security violation)
- File operations silently fail - tools report success but writes go nowhere
- Search tools work because they use different path resolution
- Terminal works because it directly accesses the remote filesystem
Attempted Solutions (All Failed)
1. Copilot Extension Location
❌ Tried: Set "remote.extensionKind": {"GitHub.copilot": ["workspace"], "GitHub.copilot-chat": ["workspace"]}
- Result: Copilot Chat completely broke with timeout error
- Reverted: Must run on "ui" for Chat to function
2. Workspace Trust
❌ Tried: Added /opt/apps/dealer to trusted folders via "Workspace Trust"
- Result: No change - still prompts "outside workspace"
3. Folder Reopening
❌ Tried: Closed workspace, used "File > Open Folder", entered /opt/apps/dealer
- Result: Workspace still shows as
\opt\apps\dealerwith backslashes
4. SSH Server Configuration
❌ Tried: Set "remote.SSH.useLocalServer": false in settings.json
- Result: No change in path resolution
5. Window Reload
❌ Tried: "Developer: Reload Window" multiple times
- Result: No change
6. Remote Server Restart
❌ Tried: Killed remote VS Code server process, restarted, reloaded window
- Result: No change - path still malformed
7. Multiple Path Formats
❌ Tried: Using /opt/apps/dealer, \opt\apps\dealer, \\opt\\apps\\dealer in file operations
- Result: All formats fail
Gemini Suggested Steps
8. VS Code Settings
❌ Tried: Explicitly set remote.SSH.remotePlatform for the host to "linux" to override incorrect OS auto-detection.
- Result: No change - path still malformed
9. VS Code Settings
❌ Tried: Unchecked terminal.integrated.inheritEnv to prevent local Windows environment variables from leaking into the remote shell.
- Result: Windows paths persist in $PATH despite setting change
10. Copilot Config
❌ Tried: Disabled github.copilot.chat.terminal.enabled to stop the injection of Windows-formatted debug strings.
- Result: Semicolon-delimited Windows paths still appearing in Linux terminal
11. Remote Priority
❌ Tried: Set "GitHub.copilot": ["workspace", "ui"] to force the base extension to prioritize the Linux file system.
- Result: Extension logic continues to default to Windows path separators ()
12. Critical Reversion
❌ Tried: Attempted to set GitHub.copilot-chat to workspace mode.
- Result: FAILED. Copilot Chat completely broke (authentication/network timeout); strictly required reversion to ["ui"].
13. Agent Instruction
❌ Tried: Created .github/copilot-instructions.md with strict rules: "Environment is Linux; Use forward slashes only."
- Result: Agent acknowledges instructions but still attempts replace_string_in_file using backslashes
14. Shell Cleanup
❌ Tried: Added a sanitization script to ~/.bashrc to scrub C:\ and ; (semicolons) from the $PATH using pure bash logic.
--- CLEAN PATH FROM WINDOWS POLLUTION ---
Use built-ins only so we don't rely on broken $PATH
_NEW_PATH=""
Use IFS=: to split properly by colons
OLD_IFS="$IFS"
IFS=':'
for entry in $PATH; do
# Only keep entries that use forward slashes AND don't have semicolons
case "$entry" in
\|;) ;; # Skip Windows backslashes and semicolons
*)
if [ -n "$entry" ]; then
if [ -z "$_NEW_PATH" ]; then _NEW_PATH="$entry"; else _NEW_PATH="$_NEW_PATH:$entry"; fi
fi
;;
esac
done
IFS="$OLD_IFS"
Ensure basic Linux paths are present if they were accidentally removed
for basic in /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin; do
case ":$_NEW_PATH:" in
:$basic:) ;;
*) _NEW_PATH="$_NEW_PATH:$basic" ;;
esac
done
export PATH="$_NEW_PATH"
unset _NEW_PATH
------------------------------------------
- Result: Successfully cleaned terminal $PATH, but Copilot Agent context still appears "poisoned" by host OS
15. Session Reset
❌ Tried: Executed Remote-SSH: Kill VS Code Server on Host to clear the environment cache and force a clean reload.
- Result: No change - path still malformed
Impact
Critical - GitHub Copilot Agent is completely non-functional for code editing in Remote-SSH workspaces.
- Cannot create new files
- Cannot read existing files
- Cannot edit/refactor code
- Cannot perform multi-file operations
- Agent reduced to terminal-only operations
This severely limits the value of Copilot Agent for remote development workflows.
Current Workaround
Using run_in_terminal tool with shell commands (cat, echo, heredoc) for all file operations:
# Create file
cat > /path/to/file.py << 'EOF'
# Python code here
Activity
Ranjit2111 commentedon Dec 22, 2025
Same issue also prevalent on Remote-WSL
reeered commentedon Dec 25, 2025
same issue
ringform commentedon Dec 27, 2025
I'm running VS Code 1.107.1 on a Windows 10 host connecting to a Ubuntu 25.04 VM on the same machine. In my experience, GitHub Copilot has worked locally on Windows without any issues but has broken numerous times over the past year when connecting to the dev container on my VM.
Adding these configuration options to the remote settings:
...allows GitHub Copilot to get past this error:
... and function somewhat (e.g. getting a response back from the model). However, it can't make changes as it normally would because of the Windows/Linux path separator issue reported here.
I've tried numerous other configuration options I've found in other GitHub issues and on Reddit, and none have solved the problem.
Edit: the source of this issue seems to be the VM losing network connectivity. For VMware Workstation Player 17, you would need to restart the
VMware NAT Servicein Windows (Win+R -services.msc) and reload the window in VS Code (Ctrl+Shift+P -Developer: Reload Window) withremote.extensionKindoptions removed.IMO, GitHub Copilot should display a network issue error message rather than "Chat took too long to get ready. Please ensure you are signed in to GitHub..." which is unhelpful and misleading.
chencyu commentedon Apr 16, 2026
Root Cause Analysis: Copilot File Tools Fail with Remote SSH +
extensionKind: ["ui"]Symptom
When Copilot extensions are forced to run on the UI (Windows) side via:
All file-manipulation agent tools (
read_file,create_file,replace_string_in_file) fail in Remote-SSH workspaces (Windows local → Linux remote). Errors include:"File \opt\apps\dealer\file.ts is outside of the workspace"Meanwhile,
file_search,grep_search, andrun_in_terminalwork normally.Root Cause
The bug is a path round-trip corruption in the agent tool pipeline. Two defects combine to produce the failure:
Defect 1:
getFilePath()applies WindowsfsPathto remote Linux URIsFile:
vscode-copilot-chat/src/platform/prompts/common/promptPathRepresentationService.ts(line 53)uri.fsPathinternally callsuriToFsPath()invscode-copilot-chat/src/util/vs/base/common/uri.ts(line 645):Effect: A remote workspace URI like
vscode-remote://ssh-remote+host/opt/apps/dealerbecomes\opt\apps\dealer(Windows backslashes) when the extension runs on the Windows UI side. This backslash-formatted path is what the LLM sees in the system prompt:The LLM consequently uses backslash paths in all tool calls.
Defect 2:
resolveToolInputPath()does not passpredominantSchemeFile:
vscode-copilot-chat/src/extension/tools/node/toolUtils.ts(line 146)When
resolveFilePath()receives\opt\apps\dealer\file.tswithout apredominantScheme:\prefix on Windows →isWindowsPath = true)URI.file('\opt\apps\dealer\file.ts')→ producesfile:///opt/apps/dealer/file.tspredominantSchemedefaults toSchemas.file, returns afile://URI directlyFile:
vscode-copilot-chat/src/platform/prompts/common/promptPathRepresentationService.ts(line 96)The Fatal Mismatch
The tool then validates the URI against workspace folders in
assertFileOkForTool():File:
vscode-copilot-chat/src/extension/tools/node/toolUtils.ts(line 182)Scheme mismatch:
file:///opt/apps/dealer/file.tsvsvscode-remote://ssh-remote+host/opt/apps/dealer→ the file is always judged as "outside the workspace."Complete Failure Chain
Why
editCodeIntentIs Not AffectededitCodeIntenthas two defenses that agent tools lack:File:
vscode-copilot-chat/src/extension/intents/node/editCodeIntent.ts(line 636)Agent tools (
resolveToolInputPath) have neither defense.Why Search Tools Are Not Affected
file_searchandgrep_searchuse VS Code APIs (workspace.findFiles()) that operate at the URI level. They query the remote filesystem through the VS Code remote file system provider, bypassing string-to-URI conversion entirely.getFilePath()(so they show backslashes in output), but the search operation itself works at the URI layer.run_in_terminalexecutes commands directly on the remote shell, completely bypassing the path resolution pipeline.Why the Bug Only Manifests with
extensionKind: ["ui"]When Copilot runs on the workspace (remote) side:
isWindowsisfalse(Linux remote)uri.fsPathproduces/opt/apps/dealer(forward slashes)URI.file('/opt/apps/dealer/file.ts')producesfile:///opt/apps/dealer/file.tsfile:///opt/apps/dealer→ schemes match, tools workWhen forced to UI (Windows) side:
isWindowsistrueuri.fsPathreplaces/with\file://scheme while workspace hasvscode-remote://Suggested Fix
Option A: Fix
resolveToolInputPath()to passpredominantSchemeMirror the pattern used in
editCodeIntent:Option B: Fix
getFilePath()for remote URIsUse
uri.path(POSIX path) instead ofuri.fsPathforvscode-remoteURIs, so the LLM always sees correct forward-slash paths for remote workspaces:Recommended: Both fixes together
Option A alone would fix the scheme mismatch. Option B alone would fix the backslash display. Applying both ensures the LLM sees correct paths AND the round-trip preserves the correct URI scheme.
Affected Code Paths (All Agent Tool Callers)
ReadFileToolextension/tools/node/readFileTool.tsxCreateFileToolextension/tools/node/createFileTool.tsxCreateDirectoryToolextension/tools/node/createDirectoryTool.tsxAbstractReplaceStringToolextension/tools/node/abstractReplaceStringTool.tsxApplyPatchToolextension/tools/node/applyPatchTool.tsxGetErrorsToolextension/tools/node/getErrorsTool.tsxViewImageToolextension/tools/node/viewImageTool.tsxI use Copilot to trace the code and analysis the root cause, hopefully helpful to development team
The problem code lines are located in vscode-copilot-chat, not vscode
prompts: fix vscode-remote path corruption in PromptPathRepresentatio…
prompts: fix vscode-remote path corruption in PromptPathRepresentatio…
prompts: fix vscode-remote path corruption in PromptPathRepresentatio…
prompts: fix vscode-remote path corruption in PromptPathRepresentatio…
prompts: fix vscode-remote path corruption in PromptPathRepresentatio…
prompts: fix vscode-remote path corruption in PromptPathRepresentatio…
vs-code-engineering commentedon Nov 6, 2026
Thanks for the detailed report and source analysis. This is the same Remote-SSH failure tracked by #280816: Copilot is forced onto the Windows UI side, remote Linux paths are converted as local paths, file tools reject them as outside the workspace, and terminal operations still work. This report additionally documents Remote-WSL confirmations and the
PromptPathRepresentationServiceround-trip in detail, which should remain part of that investigation.This issue was closed automatically as a duplicate of #280816: the VS Code sweeper proposed it and an independent second review confirmed it. If this is a different problem, reply here or reopen the issue and a maintainer will take a look.