Uh oh!
There was an error while loading. Please reload this page.
fix(opencode): DB migrating on every run for non-latest channels - #21056
fix(opencode): DB migrating on every run for non-latest channels#21056bew wants to merge 2 commits into
Conversation
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
The failing |
@bew what if the test is flaky? Can you rebase and force push so that CI runs again? |
400fd62 to
704fca0Comparebew
commented
Apr 14, 2026
I rebased on |
blake-hamm
commented
Apr 15, 2026
This branch is working for me on nixos with. TY! |
jaredmontoya
commented
Apr 15, 2026
@thdxr can this PR get a review and hopefully get merged please? |
jhol
commented
Apr 24, 2026
I ported this patch to 1.14.19 - the version I have via nixpkgs. It fixes the issue for me. |
a36c166 to
62e338eComparebew
commented
Apr 24, 2026
I rebased on latest |
bew
commented
May 15, 2026
Hello, I rebased on latest |
jaredmontoya
commented
May 15, 2026
@simonklee@thdxr@adamdotdevin@Hona@Brendonovich@nexxeln anyone? |
pwiens
commented
May 20, 2026
Heads up: this will silently break after rebase on Post-rebase, One-liner: - if (!(await Filesystem.exists(Database.Path))) {+ if (!(await Filesystem.exists(Database.getPath()))) {Cost is more than a noisy log line: I hit this in a downstream fork that pulled in the same fix you have here, then rebased past |
The marker check in index.ts was hardcoded to Global.Path.data/opencode.db, but the actual DB path is channel-aware (db.ts:getPath). On non-default channels (local dev builds, named user channels), the real file is opencode-<channel>.db, so the marker never exists and the 'one time' migration runs on every launch. Use Database.getPath() as the marker so it matches the channel-specific filename that Database.Client() actually creates. Note: upstream PR anomalyco#27615 (fc34c74) renamed Database.Path (const) to Database.getPath() (function). The earlier version of this patch used Database.Path and silently re-broke when rebased past the rename. Flagged upstream at anomalyco#21056.
bew
commented
May 20, 2026
Thanks @pwiens, I updated the PR |
mmonfox
commented
May 30, 2026
I have the same issue, agent recommended `ln -s opencode-stable.db '~/.local/share/opencode/opencode.db' on my system and referenced this PR. |
Issue for this PR
Closes#21057
Closes#16885
Replaces #16884
Type of change
What does this PR do?
This PR fixes DB migration that was running on every start of
opencodewhen installed fromnixpkgs.The nix package in nixpkgs sets
OPENCODE_CHANNEL = "stable", which makes the DB have the nameopencode-stable.dbinstead ofopencode.dbthat themarkerimplied.👉 Using the actual database path which already takes the
OPENCODE_CHANNELinto account fixes the problem.(change done manually, zero AI involved)
How did you verify your code works?
Yes, locally.
Screenshots / recordings
Checklist