Skip to content

Tool apply_patch messes up line endings in windows #37090

Closed as not planned
Closed as not planned

Description

@Stefan-Bachmann

Description

Editing files with Opencode messes up line endings in files in Windows.

Per default line endings in Windows are CRLF. However, opencode introduces LF line endings when using the builtin tool apply_patch. As I'am this problem occurs also for tool write.

Afaik a suitable merge request: #20217
This issue is related to #6348 which has been closed automatically. However, it is still a annoying issue.

Besides that I want to thank you for the amazing project!

Plugins

No response

OpenCode version

1.17.20

Steps to reproduce

  1. Use an existing code file with CRLF line endings.
  2. I use GPT 5.4 as model
  3. Use a suitable prompt such that a code line will be added.
  4. This new line should have LF endings instead of CRLF.

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Activity

  1. github-actions commented on Jul 15, 2026

    @github-actions
    Contributor

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

    Several of these were closed. If the underlying issue has not been fixed, it may be worth linking to those threads or reopening the most relevant one rather than filing a new report.

  2. Stefan-Bachmann commented on Jul 15, 2026

    @Stefan-Bachmann
    Author

    As described: It is directly related to #6348 However, this issue has been closed automatically but not resolved.
    A related merge request is #20217

  3. Mac-Moneysac commented on Aug 11, 2026

    @Mac-Moneysac

    This issue is still present in 1.18.16 - It is really annoying :(

  4. Mac-Moneysac commented on Aug 28, 2026

    @Mac-Moneysac

    #45931 might resolve this issue, too

  5. Stefan-Bachmann commented on Sep 28, 2026

    @Stefan-Bachmann
    Author

    This issue is still a thing in opencode v2 :(

  6. jeckyhl commented on Oct 1, 2026

    @jeckyhl

    I ran into this issue too, and a number of my AI sessions dragged on unnecessarily while the model was trying to restore CRLF line endings across all the modified files.

    FWIW, I’m currently using a plugin to work around the shortcomings of the native OpenCode tool.

    The plugin only works for changes made within the OpenCode session working directory.

    https://github.com/jeckyhl/jeckyhl-opencode-plugins

  7. Mac-Moneysac commented on Oct 1, 2026

    @Mac-Moneysac

    Hi,
    I've solved it with a plugin, too: https://github.com/Mac-Moneysac/opencode-fix-line-endings

    It preserves line endings and ensures typical platform line endings for new files. It is available via npm such that one can easily use it via config. It is compatible with V2.

    However, I would prefer if opencode fixes this issue.

    Thank you for your support ☺️!

  8. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions