Skip to content

Windows apply_patch fails #10360

Closed
Closed

Description

@Happy-DJ

Description

Title: [BUG] apply_patch fails on Windows with Git Bash - path truncation

Environment:

  • OpenCode version: 1.1.34
  • OS: Windows 10/11
  • Shell: Git Bash
  • Client: Desktop

Description:
When using apply_patch tool, the file path gets truncated.

Error:

Plugins

No response

OpenCode version

1.1.34

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

windows11

Terminal

Desktop、powerShell

Image

正确路径为 D:\Root\twinUpgrade\simulationPython\frontend\src\views\ScenarioView.vue

Activity

  1. github-actions commented on Jan 24, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. handsomepwy commented on Jan 25, 2026

    @handsomepwy

    Yeah I also have this exact issue where the path will be truncated and end with a capitalized D. I'm on 1.1.35 win11 GUI, GPT-5 Nano.

  3. ranqn commented on Jan 25, 2026

    @ranqn
    Contributor

    It fails on using absolute path as well, I have to instruct it to always use relative paths for apply_patch.

  4. xujinhui2015 commented on Jan 26, 2026

    @xujinhui2015

    +1

  5. ham-zax commented on Feb 3, 2026

    @ham-zax

    +1

  6. machinekoder commented on Feb 14, 2026

    @machinekoder

    The same problem appears here as well with Opus 4.6, Codex 5.3 and other models.

  7. machinekoder commented on Feb 14, 2026

    @machinekoder

    Root cause: parsePatchHeader in packages/opencode/src/patch/index.ts uses line.split(':', 2) to extract file paths from patch headers. On Windows, the drive letter colon (e.g. D:) is the first colon found, so split(':', 2) returns ['*** Update File', ' D'], truncating the path to just the drive letter. This then resolves to e.g. <project_dir>\D.

    Fix is straightforward — use .slice() after the known prefix length instead of splitting on :. PRs: #10808, #13582.

  8. machinekoder commented on Feb 14, 2026

    @machinekoder

    It fails on using absolute path as well, I have to instruct it to always use relative paths for apply_patch.

    An alternative workaround might be (not tested) to state using relative paths for tool use in the AGENTS.md or to solve in OpenCode, make it part of the tool description or system prompt. But the fix is so simple that it probably would do more harm than help to do this.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwebRelates to opencode on web / desktopwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions