Skip to content

fix: Skip bun version check for nix version#33166

Merged
rekram1-node merged 2 commits into
anomalyco:devfrom
ReStranger:fix/get-nix-build-fix-from-nixpkgs
Jun 23, 2026
Merged

fix: Skip bun version check for nix version#33166
rekram1-node merged 2 commits into
anomalyco:devfrom
ReStranger:fix/get-nix-build-fix-from-nixpkgs

Conversation

@ReStranger

@ReStranger ReStranger commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Unfortunately bun 1.3.14 has a bug that causes many nix packages to break(check out this for context: NixOS/nixpkgs#519796). It is unlikely to be corrected given the development trends of the project. So I suggest using a hack that is already used in nixpkgs to fix the opencode build

Issue for this PR

Closes #28389

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Unfortunately, most likely we will not see a fix in the upstream bun. Therefore, this seems to me to be the best way, which does not affect users of other package managers, unlike #28389. #28479 will also have to close.

IMHO, it seems to me that opencode should strive to untie itself from bun and allow the use of nodejs or deno for build. At the moment, bun rewritten in rust is quite unstable, I tried to compile opencode using bun-canary and encountered enough bugs to abandon it. Sorry for the moment of thoughts in PR

How did you verify your code works?

nix build
./result/bin/opencode --version

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- Unfortunately bun 1.3.14 has a bug that causes many nix packages to break. It is unlikely to be corrected given the development trends of the project. So I suggest using a hack that is already used in nixpkgs to fix the opencode build

Signed-off-by: ReStranger <restranger@disroot.org>
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

1. PR #32827: fix: actually relax bun version requirement to allow running with nix

2. PR #28479: chore(nix): update bun to 1.3.14

  • chore(nix): update bun to 1.3.14 #28479
  • Why related: This PR is mentioned in the current PR's description as needing to be closed. It's the upstream change that introduced the problematic bun version.

The current PR #33166 seems to be an alternative approach to fixing the bun version issue for nix builds, particularly in relation to PR #32827. You may want to check if #32827 is still open or if it was rejected for a reason before proceeding.

@JoshuaDietz

Copy link
Copy Markdown

Unfortunately for me this PR was not working. When attempting to start Opencode, after a few seconds of loading I got a SIGTRAP error. Not sure if this is specific to my system. Tried to debug a little with AI, I'm unable to verify if this is actually true:

PR #33166 only relaxes the build-time bun version check; it doesn't upgrade bun itself, so the produced binary still embeds the bun@1.3.13 runtime and crashes at runtime (SIGTRAP) when opencode code uses 1.3.14 APIs. The fix is insufficient — it moves the failure from build-time to runtime.

according to glm-5.2

Did this work for you?

@ReStranger

Copy link
Copy Markdown
Contributor Author

Unfortunately for me this PR was not working. When attempting to start Opencode, after a few seconds of loading I got a SIGTRAP error. Not sure if this is specific to my system. Tried to debug a little with AI, I'm unable to verify if this is actually true:

PR #33166 only relaxes the build-time bun version check; it doesn't upgrade bun itself, so the produced binary still embeds the bun@1.3.13 runtime and crashes at runtime (SIGTRAP) when opencode code uses 1.3.14 APIs. The fix is insufficient — it moves the failure from build-time to runtime.

according to glm-5.2

Did this work for you?

Works correctly for me. Can you provide details about your opencode settings?

@ReStranger

Copy link
Copy Markdown
Contributor Author

Unfortunately for me this PR was not working. When attempting to start Opencode, after a few seconds of loading I got a SIGTRAP error. Not sure if this is specific to my system. Tried to debug a little with AI, I'm unable to verify if this is actually true:

PR #33166 only relaxes the build-time bun version check; it doesn't upgrade bun itself, so the produced binary still embeds the bun@1.3.13 runtime and crashes at runtime (SIGTRAP) when opencode code uses 1.3.14 APIs. The fix is insufficient — it moves the failure from build-time to runtime.

according to glm-5.2

Did this work for you?

To be honest, I can't find any use of 1.3.14-specific things in the code. If you know about these, you can add patches for compatibility

@JoshuaDietz

Copy link
Copy Markdown

If it's working for you I guess something else is wrong with my config, tbh that's quite possible 😄 Will investigate further in the coming days, but that shouldn't block this PR

@ReStranger

Copy link
Copy Markdown
Contributor Author

If it's working for you I guess something else is wrong with my config, tbh that's quite possible 😄 Will investigate further in the coming days, but that shouldn't block this PR

I asked a friend to check, it also works for him, so most likely this is really a problem on your side

@rekram1-node rekram1-node merged commit e0c0411 into anomalyco:dev Jun 23, 2026
9 of 12 checks passed
markjaquith pushed a commit to markjaquith/opencode that referenced this pull request Jun 23, 2026
Signed-off-by: ReStranger <restranger@disroot.org>
Co-authored-by: dbeley <6568955+dbeley@users.noreply.github.com>
BenGu3 pushed a commit to BenGu3/opencode that referenced this pull request Jun 27, 2026
Signed-off-by: ReStranger <restranger@disroot.org>
Co-authored-by: dbeley <6568955+dbeley@users.noreply.github.com>
@jerome-benoit

Copy link
Copy Markdown
Contributor

Hi @ReStranger, thanks for the fix. One issue: this only fixes the opencode derivation, not opencode-desktop.

The PR adds the Bun version-check workaround in nix/opencode.nix via postPatch, but nix/desktop.nix defines its own derivation and its own postPatch. It inherits version, src, node_modules, and patches from opencode, but it does not inherit or run opencode.postPatch.

As a result, opencode-desktop still builds with the unmodified packages/script/src/index.ts and fails during bun ./scripts/prebuild.ts with:

This script requires bun@^1.3.14, but you are using bun@1.3.13

A fix would need to either move this workaround into a shared patches entry inherited by desktop.nix, or apply the same substituteInPlace packages/script/src/index.ts in nix/desktop.nix.postPatch as well.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nix flake fails to build: bun version mismatch

5 participants