Skip to content

Copilot Agent file tools fail with WSL path mismatch #289166

Closed as not planned
Closed as not planned

Description

@IronKeyVault

Does this issue occur when all extensions are disabled?: No (requires GitHub Copilot extension)

VS Code Version: 1.108.1
OS Version: Windows 11 + WSL2 (Ubuntu)
GitHub Copilot: 1.388.0
GitHub Copilot Chat: 0.36.1
Steps to Reproduce:

Open a WSL workspace in VS Code by running cd /home/user/project && code . from a WSL terminal
Start a Copilot Agent session (Copilot Chat in Agent mode)
Ask Copilot Agent to read or edit a file in the workspace
Observe that grep_search tool works and returns paths like \home\user\project\file.md
Observe that read_file and replace_string_in_file tools fail with "File is outside of the workspace" error for the same files
Expected: File tools should accept WSL paths and work consistently with search tools

Actual: Path format mismatch - search tools return Windows-style paths (\home\...) but file tools reject both Unix (/home/...) and Windows (\home\...) formats as "outside of workspace"

Workaround: Use terminal commands (cat, sed -i) instead, but this bypasses VS Code's diff view and user approval workflow for file changes.

Similar code found with 1 license type - View matches

Activity

  1. chrmarti commented on Jan 21, 2026

    @chrmarti
    Collaborator

    Are you running the extension on the UI side? (It needs to be run in WSL as a workspace extension, maybe you changed this in your user settings.)

  2. aeschli commented on Jan 21, 2026

    @aeschli
    Contributor

    Just to confirm, you are using the WSL extension, right? The VS Code window that opens is a remote WSL window (as indicated by WSL in the lower left corner).

    When I test this I don't see grep_search returning paths like \home\user\project\file.md
    Can you make a sample request and set the response log?
    https://github.com/microsoft/vscode/wiki/Copilot-Issues#language-model-requests-and-responses

  3. added
    info-needed
    on Jan 21, 2026
  4. IronKeyVault commented on Jan 21, 2026

    @IronKeyVault
    Author
  5. IronKeyVault commented on Jan 21, 2026

    @IronKeyVault
    Author
  6. aeschli commented on Jan 22, 2026

    @aeschli
    Contributor

    bchen36 (@bryanchen) You have worked on grep_search tool? It should not return paths with backslash when running on WSL.
    Aziki (@IronKeyVault) You did not configure the vscode-copilot-chat extension to run on the UI side, right?

  7. IronKeyVault commented on Jan 23, 2026

    @IronKeyVault
    Author

    bchen36 (@bryanchen)

    1. YES - grep_search tool returns paths with backslash on WSL:
      Example: \home\kasper\projects\private\IronKeyVault\...
      Expected: /home/kasper/projects/private/IronKeyVault/...

    2. NO - I did not manually configure vscode-copilot-chat extension to run on UI side.
      Using default settings:

    The issue is that grep_search returns backslash paths (Windows-style), but read_file/replace_string_in_file
    reject them as "outside of workspace" because they expect forward slash paths (Unix-style) on WSL.

  8. IronKeyVault commented on Jan 23, 2026

    @IronKeyVault
    Author

    IMPORTANT: The issue only occurs in THIS specific project after we moved the installation location.

    Timeline:

    • Edit tools worked before moving project location
    • After moving to /home/kasper/projects/private/IronKeyVault - edit tools stopped working
    • grep_search works (returns \home\kasper\... paths)
    • read_file/replace_string_in_file fail with "outside of workspace"

    Other projects: Edit tools work fine ✅
    This project only: Edit tools broken ❌

    Current path: /home/kasper/projects/private/IronKeyVault
    Mounted on: /dev/sdd (native WSL2 filesystem, not /mnt/c/)

    Hypothesis: Something about the path "/home/kasper/projects/private/IronKeyVault" causes
    path mapping mismatch between grep_search (returns backslash) and read_file (expects forward slash).

    Question: Is there a VS Code workspace cache or path mapping cache that needs to be cleared
    after moving a project location?

  9. IronKeyVault commented on Jan 23, 2026

    @IronKeyVault
    Author

    UPDATE: Tried clearing workspace cache and reopening - issue persists.

    Steps attempted:

    1. Removed .vscode/.history
    2. Cleared ~/.vscode-server/data/User/workspaceStorage/*
    3. Reopened workspace with code .
    4. Reopened with absolute realpath
      Result: Edit tools still fail with "outside of workspace"

    This confirms it's a persistent bug related to this specific project path
    (/home/kasper/projects/private/IronKeyVault), not a cache issue.

    The bug is reproducible after project relocation and survives workspace cache clearing.

  10. aeschli commented on Jan 23, 2026

    @aeschli
    Contributor

    There's no cache on workspace folders. What exactly are the URIs of the workspace folders? The request log would show that somewhere in the prompt. It would great if you could provide the request log (copilotmd file) of a simple call and attach it here maybe you can erase all confidential information

  11. IronKeyVault commented on Jan 24, 2026

    @IronKeyVault
    Author

    Thanks for looking into this!

    Here's the request log showing the path transformation issue:

    Logs taken from ctrl+shift u -> github copilot chat:output

    2026-01-24 05:58:23.707 [error] Error from tool read_file with args
    {"filePath": "/home/kasper/projects/private/IronKeyVault/README.md", "startLine": 1, "endLine": 5}:
    File \home\kasper\projects\private\IronKeyVault\README.md is outside of the workspace...
    at aIe (c:\Users\KasperElsborg.vscode\extensions\github.copilot-chat-0.36.2\dist\extension.js:1257:37953)
    at async Hfe.prepareInvocation (...)

  12. 3 remaining items

  13. IronKeyVault commented on Jan 28, 2026

    @IronKeyVault
    Author

    I had copilot summon up the issue her.

    Environment

    • VS Code 1.108.1
    • GitHub Copilot Chat 0.36.2
    • Windows 11 + WSL2 / Remote SSH (Rocky Linux)

    Bug Description

    Copilot Agent's read_file and replace_string_in_file tools fail on all Unix-based remote connections (WSL, SSH). The tools reject valid file paths as "outside of workspace" or "file does not exist".

    Root Cause

    uriToFsPath() in VS Code core converts Unix paths (/home/user/...) to invalid Windows paths (\home\user\...) regardless of the actual filesystem.

    Key Finding: State-Dependent Behavior

    File State | read_file | replace_string_in_file -- | -- | -- Pre-existing in workspace | ❌ FAILS | ❌ FAILS Created via create_file tool | ✅ WORKS | ✅ WORKS

    Files created fresh via Copilot's create_file tool work correctly. Pre-existing files have corrupted path mappings in VS Code's internal cache.

    Affected Tools

    • ❌ read_file - broken on pre-existing files
    • ❌ replace_string_in_file - broken on pre-existing files
    • ✅ grep_search - works
    • ✅ run_in_terminal - works
    • ✅ create_file - works

    Workaround

    Delete file via terminal, recreate via create_file tool. Impractical for routine use.

  14. IronKeyVault commented on Jan 30, 2026

    @IronKeyVault
    Author

    Bug Report: Copilot Agent file tools fail with Unix path conversion on Remote SSH

    Environment

    Component Version
    VS Code 1.108.1
    GitHub Copilot 1.388.0
    GitHub Copilot Chat 0.36.2
    Host OS Windows 11
    Remote Rocky Linux 9 via Remote-SSH

    Problem Summary

    Copilot Agent's read_file and replace_string_in_file tools fail on all existing files when connected via Remote-SSH (or WSL). The tools receive valid Unix paths but VS Code converts them to invalid Windows-style backslash paths internally.

    Minimal Reproduction Steps

    Setup

    1. Connect VS Code to a Linux remote via Remote-SSH (or WSL)
    2. Create a test file:
      mkdir -p /tmp/copilot-bug-repro
      echo "Test content line 1" > /tmp/copilot-bug-repro/test.md
      echo "Test content line 2" >> /tmp/copilot-bug-repro/test.md
    3. Open the folder in VS Code: code /tmp/copilot-bug-repro

    Reproduce

    1. Open Copilot Chat (Agent mode)
    2. Type: Read the file /tmp/copilot-bug-repro/test.md
    3. Observe the error

    Expected Result

    File content is returned successfully.

    Actual Result

    ERROR: cannot open file:///tmp/copilot-bug-repro/test.md
    Detail: Unable to read file '\tmp\copilot-bug-repro\test.md'
    (Error: Unable to resolve nonexistent file '\tmp\copilot-bug-repro\test.md')
    

    Root Cause Analysis

    The tool receives the correct Unix path:

    /tmp/copilot-bug-repro/test.md
    

    But the error shows a Windows-style backslash path:

    \tmp\copilot-bug-repro\test.md
    

    The bug appears to be in uriToFsPath() in VS Code's URI handling:

    // In uri.ts
    if (isWindows) {
        value = value.replace(/\//g, '\\');
    }

    This code runs because the VS Code host is Windows, but it incorrectly converts Unix paths from the remote filesystem.

    Tool Status Matrix

    Tool Status Notes
    grep_search ✅ Works
    semantic_search ✅ Works
    file_search ✅ Works
    run_in_terminal ✅ Works
    create_file ✅ Works New files work correctly
    read_file ❌ FAILS "Unable to resolve nonexistent file"
    replace_string_in_file ❌ FAILS Same error
    list_dir ❌ FAILS Same error

    Key Observation

    Files created via create_file tool work correctly with read_file and replace_string_in_file. Only pre-existing files fail. This suggests the tool registration uses correct paths for newly created files but has corrupted path mappings for existing workspace files.

    Window Output Log (Key Error)

    2026-01-29 09:05:29.787 [error] [Window] [LanguageModelToolsService#invokeTool] Error from tool copilot_readFile with parameters {"filePath":"/home/kasperadm/IronKeyVault/CLAUDE.md","startLine":1,"endLine":200}:
    cannot open file:///home/kasperadm/IronKeyVault/CLAUDE.md. Detail: Unable to read file '\home\kasperadm\IronKeyVault\CLAUDE.md' (Error: Unable to resolve nonexistent file '\home\kasperadm\IronKeyVault\CLAUDE.md')
        at sUe.$tryOpenDocument (vscode-file://vscode-app/c:/Users/kasper/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:542:8532)
    

    Multiple similar errors for different files:

    • /home/kasperadm/IronKeyVault/docs/internal/ADR.../ADR-150-identity-integration-architecture.md
    • /home/kasperadm/IronKeyVault/docs/internal/ADR.../ADR-140-login-authc-flow-user_admin-web.md
    • /home/kasperadm/IronKeyVault/scripts/dev/modules/10-nginx.sh

    All show same pattern: Unix path input → backslash path in error.

    Proposed Fix

    In uri.ts uriToFsPath() function, detect and preserve Unix paths:

    // Before
    if (isWindows) {
        value = value.replace(/\//g, '\\');
    }
    
    // After - don't convert Unix paths on Windows host
    if (isWindows && !value.startsWith('/')) {
        value = value.replace(/\//g, '\\');
    }

    Impact

    This bug makes Copilot Agent's file editing capabilities completely non-functional for:

    • Remote-SSH connections from Windows to Linux
    • WSL workspaces
    • Any scenario where Windows VS Code accesses Unix filesystems

    Request Log

    See attached: chat-replay-2026-01-30.json

    chat-replay-2026-01-30.json

  15. IronKeyVault commented on Jan 30, 2026

    @IronKeyVault
    Author

    Bryan Chen (@bryanchen-d)

    Looks like the issue is from here: https://github.com/microsoft/vscode-copilot-chat/blob/52f9199636edfe41ac7d9d0af60b38b68facc395/src/util/vs/base/common/uri.ts#L645-L647

    Ignore this, if the extension is running on the WSL side, then isWindows should return false and it shouldn't replace the slashes.

    GitHub Reply to MS Developer

    Context: MS developer responded thinking the extension runs on WSL/remote side.


    Thanks for looking into this! I think there might be a misunderstanding about the architecture.

    The extension runs on the Windows host, not on WSL/remote side.

    ┌─────────────────────────────────────────────────────────────┐
    │ Windows 11 Host (isWindows = true ✓ correct)               │
    │ ┌─────────────────────────────────────────────────────────┐ │
    │ │ VS Code + Copilot Chat Extension                        │ │
    │ │ - uriToFsPath() runs HERE                               │ │
    │ │ - isWindows returns TRUE (correct!)                     │ │
    │ └─────────────────────────────────────────────────────────┘ │
    │                          │ SSH                              │
    │                          ▼                                  │
    │ ┌─────────────────────────────────────────────────────────┐ │
    │ │ Remote: Rocky Linux 9 (via Remote-SSH)                  │ │
    │ │ - Filesystem paths: /home/user/project/file.md          │ │
    │ │ - Extension does NOT run here                           │ │
    │ └─────────────────────────────────────────────────────────┘ │
    └─────────────────────────────────────────────────────────────┘
    

    The problem:

    • isWindows correctly returns true (host is Windows)
    • But the paths come from the remote Unix filesystem
    • uriToFsPath() converts ALL paths to backslashes when isWindows=true
    • Unix path /home/user/file.md becomes \home\user\file.md → invalid

    The fix should check the path origin, not just host OS:

    // Current (problematic)
    if (isWindows) {
        value = value.replace(/\//g, '\\');
    }
    
    // Proposed fix
    if (isWindows && !value.startsWith('/')) {
        value = value.replace(/\//g, '\\');
    }

    Paths starting with / are definitionally Unix paths and should never be converted to backslashes, regardless of which OS the extension runs on.

  16. bryanchen-d commented on Jan 30, 2026

    @bryanchen-d
    Collaborator

    By default it should be running on the WSL side. Aziki (@IronKeyVault) can you open command center (ctrl+shift+P) and run command "Show running extensions", in the Running Extensions window, check if the Github copilot chat extension is running from WSL?

  17. IronKeyVault commented on Jan 31, 2026

    @IronKeyVault
    Author

    Bryan Chen (@bryanchen-d) you you are right. it runs on the remote side. I tried to spin up a linux rocky on a vm, to see if it made a difference. but no the issue is still here.

  18. aeschli commented on Feb 2, 2026

    @aeschli
    Contributor

    Your request logs contains:

    <environment_info>
    The user's current OS is: Windows
    </environment_info>
    <workspace_info>
    I am working in a workspace with the following folders:
    - \\home\\kasperadm\\IronKeyVault 
    

    When I run on WSL it says:

    
    <environment_info>
    The user's current OS is: Linux
    </environment_info>
    <workspace_info>
    I am working in a workspace with the following folders:
    - /home/aeschli/workspaces/testing/prompt 
    

    The OS we get from the node.process.
    It would mean that your Copilot Chat extension runs on the UI side, or you are not in a remote WSL setup.

    Here's how this should look.

    Image
  19. IronKeyVault commented on Feb 2, 2026

    @IronKeyVault
    Author
  20. aeschli commented on Feb 3, 2026

    @aeschli
    Contributor

    Best is to remove the entire remote.extensionKind section from your settings and use the defaults. This is a advanced setting and not all extensions can be configured like that.

  21. IronKeyVault commented on Feb 7, 2026

    @IronKeyVault
    Author

    Go ahead and close the case

  22. dcuccia commented on Feb 13, 2026

    @dcuccia

    Stumbled on this too - here's the summary on my end: #280816 (comment)

  23. IronKeyVault commented on Feb 14, 2026

    @IronKeyVault
    Author

    Stumbled on this too - here's the summary on my end: #280816 (comment)

    excatly same fix here.

  24. locked and limited conversation to collaborators on Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

info-needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions