Skip to content

[Bug]: config migration creates new .bak file every launch on Windows #3643

@iCrazeiOS

Description

@iCrazeiOS

Prerequisites

  • I will write this issue in English (see our Language Policy)
  • I have searched existing issues to avoid duplicates
  • I am using the latest version of oh-my-opencode
  • I have read the documentation or asked an AI coding agent with this project's GitHub URL loaded and couldn't find the answer

Bug Description

Running OMO v3.17.5 on Windows 11.

Every time opencode starts, the plugin makes another oh-my-openagent.json.bak.<timestamp> next to my config and never actually writes the migrated file.

The plugin log shows:
Failed to write migrated config to ...\oh-my-openagent.json: {"code":"EPERM","fd":5,"syscall":"fsync","errno":-1}

On Windows, fsync requires the handle to have GENERIC_WRITE access, meaning our read-only fd gets ACCESS_DENIED (node EPERM).

Because the throw happens before renameSync, the rename never runs, the orphan .tmp is left behind, and the migration retriggers on every launch, producing another backup file.

Steps to Reproduce

On a Windows machine:

  1. Install plugin: add "oh-my-openagent@3.17.5" to opencode.json plugins.
  2. Put any model in MODEL_VERSION_MAP in the config — e.g. set an agent's model to openai/gpt-5.3-codex in oh-my-openagent.json.
  3. Launch opencode. Quit. Launch again. Quit. Repeat.
  4. Look in ~\.config\opencode\: a new oh-my-openagent.json.bak.<timestamp> shows up after every launch, as well as a leftover oh-my-openagent.json.tmp. The original json is never updated.

Expected Behavior

The migration to succeed

Actual Behavior

Migration retriggers on every launch, producing another backup file.

Doctor Output

oMoMoMoMo Doctor

⚠ 1 issue found:

1. GitHub CLI missing
   gh CLI is not installed.
   Fix: Install from https://cli.github.com/
   Affects: GitHub automation

Error Logs

Failed to write migrated config to ...\oh-my-openagent.json: {"code":"EPERM","fd":5,"syscall":"fsync","errno":-1}

Pull Request

Fixed via #3644

Operating System

Windows

OpenCode Version

1.14.25

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions