The SDK could not be published at all — bun publish runs prepare, and prepare needs bun2nix #115

Merged
enricobuehler merged 1 commits from worktree-sdk-publish-prepare-hook into main 2026-08-08 11:04:34 +00:00
Owner

sdk-v0.1.3 failed at the publish step: bun2nix: command not found, exit 127. Nothing reached the registry, so 0.1.3 is still free@punktfunk/host is still at 0.1.2.

What happened

bun publish runs the prepare lifecycle script, and sdk's prepare is bun2nix -o bun.nix — regenerating the nix dependency file. bun2nix is a repo-maintenance tool, not something the oven/bun:1 publish container has; the workflow's own install is --ignore-scripts, so nothing put it on PATH either.

bun publish v1.3.14
$ bun run build
$ tsc -p tsconfig.build.json
$ bun2nix -o bun.nix
/usr/bin/bash: line 1: bun2nix: command not found
error: script "prepare" exited with code 127

This was latent, not new

prepare gained the bun2nix call on 2026-07-27 (1db8f763, "move the bun packages to bun2nix"), while the last SDK publish was 0.1.2, bumped 2026-07-20. So the hook has been broken for every SDK release since it landed — 0.1.3 is just the first one to try it.

@punktfunk/plugin-kit has no prepare at all, which is why kit 0.3.2 published fine inside that window and this stayed hidden.

Why not just copy web

web/package.json does the same job from postinstall. That is correct for web — it is never published — and would be worse here: a published package's postinstall runs in every consumer's install, so every plugin depending on @punktfunk/host would try to run bun2nix and fail.

prepare is the right hook for a published package (it does not run for consumers). It just must not assume a repo-maintenance tool exists wherever a publish happens.

The fix

The script skips when bun2nix is absent — and only then:

"prepare": "if command -v bun2nix >/dev/null 2>&1; then bun2nix -o bun.nix; fi"

A present-but-failing bun2nix still fails the script. Swallowing that (|| true) would let a publish go out with a silently stale bun.nix, which is the exact hand-maintained-hash problem 1db8f763 set out to end.

Verification

Both directions measured against the same sh -e that bun and the Gitea runner use for lifecycle steps:

case exit want
bun2nix absent (the publish container) 0 0
bun2nix present but failing 3 non-zero

bun publish --dry-run now completes and reports + @punktfunk/host@0.1.3, and the packed dist/ui.js:139 carries the category forwarding that is the point of the 0.1.3 release.

After merge

I will delete and re-push sdk-v0.1.3 (it published nothing, so the version is not burned), confirm the run goes green and that 0.1.3 actually appears on the registry, then tag plugin-kit-v0.3.3 — that order matters, since kit 0.3.3's peer range requires @punktfunk/host ^0.1.3 and publishing it first would leave a window where the kit is uninstallable.

`sdk-v0.1.3` failed at the publish step: **`bun2nix: command not found`, exit 127**. Nothing reached the registry, so **0.1.3 is still free** — `@punktfunk/host` is still at 0.1.2. ## What happened `bun publish` runs the `prepare` lifecycle script, and sdk's `prepare` is `bun2nix -o bun.nix` — regenerating the nix dependency file. bun2nix is a repo-maintenance tool, not something the `oven/bun:1` publish container has; the workflow's own install is `--ignore-scripts`, so nothing put it on PATH either. ``` bun publish v1.3.14 $ bun run build $ tsc -p tsconfig.build.json $ bun2nix -o bun.nix /usr/bin/bash: line 1: bun2nix: command not found error: script "prepare" exited with code 127 ``` ## This was latent, not new `prepare` gained the bun2nix call on **2026-07-27** (`1db8f763`, *"move the bun packages to bun2nix"*), while the last SDK publish was 0.1.2, bumped **2026-07-20**. So the hook has been broken for **every** SDK release since it landed — 0.1.3 is just the first one to try it. `@punktfunk/plugin-kit` has no `prepare` at all, which is why kit 0.3.2 published fine inside that window and this stayed hidden. ## Why not just copy web `web/package.json` does the same job from **`postinstall`**. That is correct for web — it is never published — and would be *worse* here: a published package's `postinstall` runs in every **consumer's** install, so every plugin depending on `@punktfunk/host` would try to run bun2nix and fail. `prepare` is the right hook for a published package (it does not run for consumers). It just must not assume a repo-maintenance tool exists wherever a publish happens. ## The fix The script skips when bun2nix is absent — and **only** then: ``` "prepare": "if command -v bun2nix >/dev/null 2>&1; then bun2nix -o bun.nix; fi" ``` A present-but-failing bun2nix still fails the script. Swallowing that (`|| true`) would let a publish go out with a silently stale `bun.nix`, which is the exact hand-maintained-hash problem `1db8f763` set out to end. ## Verification Both directions measured against the same `sh -e` that bun and the Gitea runner use for lifecycle steps: | case | exit | want | |---|---|---| | bun2nix absent (the publish container) | 0 | 0 | | bun2nix present but failing | 3 | non-zero | `bun publish --dry-run` now completes and reports `+ @punktfunk/host@0.1.3`, and the packed `dist/ui.js:139` carries the `category` forwarding that is the point of the 0.1.3 release. ## After merge I will delete and re-push `sdk-v0.1.3` (it published nothing, so the version is not burned), confirm the run goes green and that 0.1.3 actually appears on the registry, then tag `plugin-kit-v0.3.3` — that order matters, since kit 0.3.3's peer range requires `@punktfunk/host ^0.1.3` and publishing it first would leave a window where the kit is uninstallable.
enricobuehler added 1 commit 2026-08-08 10:56:08 +00:00
fix(ci/sdk): the SDK could not be published at all — bun publish runs prepare
ci / web (pull_request) Successful in 1m10s
ci / rust-arm64 (pull_request) Successful in 2m28s
ci / docs-site (pull_request) Successful in 1m23s
ci / bun-nix (pull_request) Successful in 26s
ci / rust (pull_request) Successful in 4m45s
nix / flake (pull_request) Successful in 15m6s
1df39d9617
`sdk-v0.1.3` failed at the publish step with `bun2nix: command not found`, exit 127.
Nothing was published, so 0.1.3 is still free.

`bun publish` runs the `prepare` lifecycle script, and sdk's `prepare` is
`bun2nix -o bun.nix` — regenerating the nix dependency file. That tool is a
devDependency of the repo, not something the `oven/bun:1` publish container has, and
the workflow's own install is `--ignore-scripts`, so nothing put it on PATH either.

This was latent, not new. `prepare` gained the bun2nix call on 2026-07-27 (1db8f763,
"move the bun packages to bun2nix"), while the last SDK publish was 0.1.2, bumped
2026-07-20. So the hook has been broken for every SDK release since it landed, and
0.1.3 is simply the first one to try. `@punktfunk/plugin-kit` has no `prepare` and was
never affected, which is why kit 0.3.2 published fine in that window and hid this.

The fix is NOT to copy `web/package.json`, which does the same job from `postinstall`.
That is right for web — it is never published — and would be worse here: a published
package's `postinstall` runs in every CONSUMER's install, so every plugin depending on
`@punktfunk/host` would try to run bun2nix and fail. `prepare` is the correct hook for
a published package (it does not run for consumers); it just must not assume a
repo-maintenance tool exists wherever a publish happens.

So the script skips when bun2nix is absent — and ONLY then. A present-but-failing
bun2nix still fails the script, because swallowing that would publish with a silently
stale bun.nix, which is the exact hand-maintained-hash problem 1db8f763 set out to end.
Both directions measured against the same `sh -e` bun and the Gitea runner use:
absent → exit 0, present-and-failing → exit 3.

`bun publish --dry-run` now completes and reports `+ @punktfunk/host@0.1.3`.
enricobuehler merged commit 27ceab2f6c into main 2026-08-08 11:04:34 +00:00
enricobuehler deleted branch worktree-sdk-publish-prepare-hook 2026-08-08 11:04:41 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unom/punktfunk#115