anomalyco / anomalyco/opencode

[BUG]: core migration generator (script/migration.ts) fails on Windows with ENOENT

Open
#44,401 0 comments 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Aug 23, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Running bun script/migration.ts --name <anything> from packages/core on Windows fails after drizzle-kit generates the migration:

[✓] Your SQL migration ➜ E:\Temp\opencode-core-migration-XXXX\incremental\<name>\migration.sql 🚀

ENOENT: no such file or directory, open 'E:\Temp\...\incremental\<name>\migration.sql\migration.sql'

Note the doubled migration.sql\migration.sql — the script's generatedMigrations() helper finds files via new Bun.Glob("*/migration.sql").scan(), which yields backslash-separated paths on Windows. file.split("/")[0] then fails to isolate the directory name, so <dir>\migration.sql is used as the migration name and every subsequent path join is wrong. The same broken split also affects --check, so the schema-consistency gate can't pass on Windows either.

Fix is to split on both separators: file.split(/[\\/]/)[0].

Plugins

None.

OpenCode version

v1.18.18 (dev checkout, packages/core script).

Steps to reproduce
  1. On Windows, in a dev checkout of the repo, edit packages/core/src/session/sql.ts (any schema change).
  2. cd packages/core && bun script/migration.ts --name test_idx.
  3. drizzle-kit succeeds, then the script dies with ENOENT before writing any files.
Screenshot and/or share link

N/A (CLI output above).

Operating System

Windows 11 (Bun 1.3.9). Works fine on Linux/macOS where glob paths use /.

Terminal

Windows Terminal.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.