Skip to content

fix(cli): pnpm install, add and remove exit 0 in patch repos - #1176

Merged
allisonmahmood merged 1 commit into
mainfrom
fix/workerd-builds-1170
Nov 4, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
fix/workerd-builds-1170

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

What changed

With pnpm 12, pnpm install, pnpm add and pnpm remove in a tier 2 patch repo failed with ERR_PNPM_IGNORED_BUILDS … Ignored build scripts: workerd, even though each still applied its change. Agents couldn't trust the exit code. pnpm 12 also runs an install before every pnpm patchy … command, so that error printed there too.

Patchy runs workerd's platform binary directly, so its install script isn't needed. A patch repo's pnpm-workspace.yaml now declines it:

# Patchy runs workerd's binary itself; its install script is not needed.
allowBuilds:
  workerd: false

The installed release's generation step adds this entry, so init, refresh and pull all write it, including a refresh started by an older CLI. It edits only plain layouts: one document with LF or CRLF line breaks whose block mapping starts at column 0, with no anchors, aliases, merge keys, ? keys, tags or document markers, and allowBuilds absent, or a block or one-line flow mapping whose keys are all scalars. Any other file is left byte for byte, and refresh warns with the line to add: allowBuilds: { workerd: false }, or workerd: false under the existing allowBuilds. A choice the repo already made for workerd is kept, through aliases or merge keys too.

Closes #1170

Look at

  • Where the write lives. declineWorkerdBuild runs in Project.generate, the step the newly installed release always runs. pnpm patchy refresh in an older repo runs that repo's old CLI, and code only in the invoking CLI's refresh would not land until a second refresh.

  • What gets edited. withWorkerdBuildDeclined in the new workerdBuild.ts parses the file with yaml and returns either the file to write or a notice.

    • It first resolves the settings as pnpm reads them: aliases and merges included, and line breaks normalised to LF, since YAML and pnpm treat a bare CR as one. If allowBuilds already names workerd (workerd: true, "workerd": false, workerd@<version>, or inherited through <<), the file is kept.
    • Otherwise it splices workerd: false into plain layouts only, judged from the parse and the lexer's tokens: one document with LF or CRLF line breaks, a block mapping at column 0, none of anchors, aliases, merge keys, ? keys, tags or document markers, and allowBuilds absent, or a block or one-line flow mapping whose keys are all scalars. Only a flow mapping with no entries is replaced whole. Quoted keys are fine.
    • For anything else it changes nothing and returns the line to add. That covers a ... marker, an anchored or aliased key, explicit keys, merge keys, an empty or null value, an indented or flow root, a multi-line flow mapping, a tag, two documents, a duplicate key, any bare CR, and a non-scalar key such as { [esbuild]: true }. yaml's own console logging is off, so refresh's output stays clean.
  • Where the warning comes from. Refresh runs the installed release's toolchainChild.js inspect after generation, and every CLI since early October relays that reply's warnings. The inspection reads the file generation left and adds the notice there, so an older CLI's refresh shows it too.

  • One new bundled dependency, yaml 2.9.1. It was already in the lockfile through Vite, so no new package enters the tree. It has no dependencies of its own, and its ISC licence now ships in dist/licenses/. The CLI bundle grows from about 3.79 MB to 4.07 MB, unminified. It's used only to parse; the edit is a splice into the original text, so nothing else is reformatted.

  • A real old repo, on a local dev environment. I scaffolded a tier 2 repo with main's CLI, then restarted the instance on this branch:

    Step Result
    Old repo, before refresh: pnpm add -D [email protected], pnpm remove is-number, pnpm install --force each exit 1, ERR_PNPM_IGNORED_BUILDS … [email protected]
    Give it its own pnpm-workspace.yaml (minimumReleaseAge: 1440), then pnpm patchy refresh --json with the repo's own old CLI exit 0, pin changed, warnings: []
    pnpm-workspace.yaml afterwards minimumReleaseAge: 1440, then the block above
    pnpm install --force, pnpm add -D [email protected], pnpm remove is-number each exit 0
    pnpm patchy dev, then calling the starter's notes.list handler healthy; {"ok":true,"value":[]}, logged as a tier 2 query invocation with outcome success
    patchy init --tier 2 from the environment's global CLI, still the old one the new repo has the file; install, add and remove each exit 0

    A plain pnpm install right after init exits 0 even before the fix, because there is nothing to link. --force relinks, so pnpm decides about workerd again.

Merging with #1185

#1185 changes the same warnings: expression in packages/patchy/src/toolchainChild.ts, and taking either side drops the other's warning. Whichever PR lands second resolves it like this, so the loaded-toolchain, TypeScript and workspace warnings all survive:

  • Imports: keep both. Each changes import { writeFile } to import { readFile, writeFile } from "node:fs/promises";. Keep both import { typescriptManifest, typescriptNotice } from "./typescriptNotice.js"; and import { withWorkerdBuildDeclined } from "./workerdBuild.js";.

  • Before output(: keep both declarations, fix(cli): refresh from an old CLI warns about TypeScript 7 #1185's const typescript = inspect ? typescriptNotice(…) : undefined; and this PR's const workspace = inspect ? withWorkerdBuildDeclined(…) : undefined;.

  • The expression: replace both sides' warnings: with

    warnings: [
      ...loaded.warnings,
      ...(typescript === undefined ? [] : [typescript]),
      ...(workspace !== undefined && "notice" in workspace ? [workspace.notice] : [])
    ],

How it was verified

  • vitest run src/workerdBuild.test.ts src/packagePin.test.ts: 48 passed. workerdBuild.test.ts has 8 plain layouts that are edited, 8 existing workerd choices that are kept (block, quoted, flow, version-specific, aliased key, aliased mapping, merged, across bare CR breaks), and 18 files that are left byte for byte with the right line to add. Sol's latest two cases, a bare CR and a non-scalar flow key, were red before this commit.
  • vitest run src/cliRepo.test.ts -t "pnpm-workspace|refreshes the generated client", against a rebuilt CLI: refresh keeps a repo's minimumReleaseAge and adds the entry. For allowBuilds: { # keep me\n}, it leaves the file byte for byte and its --json warnings carry the notice.
  • Real pnpm 12.9.1 on fixtures, in a scratch project with workerd as a devDependency, running pnpm install --frozen-lockfile --force:
    • edited flow mapping, edited quoted key and appended block: exit 0;
    • kept: a merged workerd: false, and allowBuilds: {\r workerd: false\r} with bare CRs: exit 0;
    • left as written: a ... marker, an anchored flow key, a bare-CR block mapping without workerd, and { [esbuild]: true, sharp: true }: exit 1, which is what their notice tells the person to fix.
  • packed-tier2-e2e.mjs now runs pnpm install --frozen-lockfile --force in the freshly initialized tier 2 repo, which fails without the entry, before going on to use workerd through patchy dev.
  • pnpm lint, effect-tsgo on the package and tsconfig.test.json, bun fmt: clean.
  • CI passed every check on the first head (22 pass, 2 skipped), including tier2-smoke with the new pnpm install --frozen-lockfile --force step. This head is running CI now.
  • Not run locally: pnpm verify and a before/after pnpm dev transcript. The shared machine's heavy-command lock had a queue hours long, and CI ran the same suites.
  • README, ADR-0004 and the patchy-loop skill's list of managed writes now include the entry.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Repos gain a pnpm-workspace.yaml, or one entry in theirs, on their next init, refresh or pull. A hand-written file in a layout refresh doesn't edit gets a warning naming the one line to add.

  • What does a revert leave behind? Repos with allowBuilds: workerd: false in pnpm-workspace.yaml.
  • Does the release before it still work with that? Yes. The previous release never reads that file, and its own installs pass --ignore-workspace --ignore-scripts.

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, through T3 Code.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines labels Nov 1, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review (GPT 6.1 Sol, xhigh) on 3fd4157: request changes, two P2s, being fixed.

  1. A quoted "allowBuilds": key isn't recognised, so refresh appends a second mapping, which is a duplicate-key YAML error that breaks install.
  2. A flow mapping is left unchanged. allowBuilds: { esbuild: true } makes no workerd choice, so pnpm still exits 1.

Found sound:

  • Block mappings keep their explicit choices and minimumReleaseAge.
  • Install, add, remove and a forced reinstall all pass.
  • A repo invoking its own old CLI gets the setting on its first refresh.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Re-check (GPT 6.1 Sol, xhigh) on 1100439: FAIL. Both original findings are closed, but inserting into the text still breaks eight valid YAML forms:

  • document-end markers;
  • anchors on flow keys;
  • explicit ? keys;
  • aliases, and <<: merge keys;
  • indented roots and flow roots;
  • comments inside an empty flow mapping.

Next: narrow the edit to the plain layouts Patchy scaffolds. Leave anything else byte-for-byte unchanged, with a refresh warning that gives the exact line to add. Each of those forms becomes a test case.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Re-check (GPT 6.1 Sol, xhigh) on b3cd107: FAIL, two gaps, being fixed. The eight earlier forms now stay unchanged and warn, confirmed through a real pre-change CLI, and existing choices, aliases and merges included, are kept.

  • P2: bare CR line endings hide an existing workerd choice from the parser, so a duplicate key gets inserted. Refresh exits 0, then pnpm can't parse the file. Fix: any bare CR means the file isn't a plain layout, so it's left unchanged with a warning.
  • P3: a flow mapping with a collection key ({ [esbuild]: true, sharp: true }) is replaced as if empty. Fix: replace only a mapping that parses with zero entries.
  • Merge note: fix(cli): refresh from an old CLI warns about TypeScript 7 #1185 edits the same warnings: expression in toolchainChild.ts. Whichever PR lands second must keep the loaded-toolchain, workspace and TypeScript warnings.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Re-check (GPT 6.1 Sol, xhigh) on 23649c2: PASS, no findings.

  • Both earlier findings are closed. Three regression tests fail on b3cd107 and pass on the head.
  • Edit positions: they come from parsing the original text whenever normalising changes it. CRLF and Unicode-prefix probes passed.
  • Generated inputs: across 13,263, every edit kept the other YAML values and stayed valid and idempotent. Another 1,180 existing-choice cases stayed unchanged, with no warning.
  • Real pnpm 12: forced install, add and remove pass on the edited fixtures, with minimumReleaseAge kept.
  • Merging with fix(cli): refresh from an old CLI warns about TypeScript 7 #1185: the recipe keeps the loaded-toolchain, TypeScript and workspace warnings together.
  • Docs and tests: the docs match the code. 48 focused tests, two refresh integration tests and the typechecks pass.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 23649c27bf646f75e44b4a680f7ba0147a3df7d9 (base 1f187a92b2c20da81e8a1d647ea28a60a075d6ef) on team, by Claude Opus 5.5 in Claude Code, through T3 Code.

Every repo below was a tier 2 repo on a local dev environment at the head, with real pnpm 12.9.1. The "older" repos were scaffolded, then pinned back to a built patchy 0.13.0 tarball with its workspace file removed, so pnpm patchy refresh ran 0.13.0's own CLI. After each step I ran pnpm install, pnpm install --force, pnpm add -D [email protected] and pnpm remove is-number. I checked whether workerd's postinstall ran (bin/workerd stays the JS shim unless it does), read minimumReleaseAge back with pnpm config get, and ran pnpm patchy dev --json with an agent/ mutation and query called through pnpm patchy dev agent.

Done means

  • New repo: install, add and remove exit 0 without running workerd's script: passed. patchy init --tier 2 wrote the three-line entry. All four pnpm commands exit 0, the shim is untouched, and patchy dev is healthy with 2 workerd processes under the session. accAddNote and accListNotes both succeed.

  • Older repo refreshed through its own 0.13.0 CLI: passed. Before refresh, the bug reproduces:

    pnpm install --force: exit 1
        Error: ERR_PNPM_IGNORED_BUILDS
          ╰─▶ Ignored build scripts: [email protected]
    pnpm add -D [email protected]: exit 1   (same error)
    pnpm remove is-number: exit 1         (same error)
    

    pnpm patchy refresh --json exits 0, with release: { from: "0.13.0", to: "0.34.0" } and warnings: []. It passed with no workspace file (the file is created) and with the repo's own # Our own settings / minimumReleaseAge: 2880 (the entry is appended below them). Afterwards all four pnpm commands exit 0 and the shim is untouched. The handler runs in workerd under patchy dev.

  • The repo's own explicit choices, and minimumReleaseAge, are left as they are: passed.

    • An older repo with minimumReleaseAge: 2880 and allowBuilds: { esbuild: true, workerd: true # we want the postinstall } (block form) is byte-identical after the 0.13.0 CLI's refresh, with warnings: []. pnpm honours the choice: workerd's postinstall ran, and all four commands exit 0. patchy dev still runs the handler in workerd.
    • pnpm config get minimumReleaseAge reads 2880 before and after in every repo that set it. No global pnpm config file was written.
  • Unusual layout, left as written with the warning: passed. An older repo has minimumReleaseAge: 2880 and a multi-line flow mapping, allowBuilds: { / esbuild: true, / sharp: true / }. That file is not among the PR's test cases. The 0.13.0 CLI's refresh exits 0 and leaves the file byte-identical. Both --json and text mode relay the warning:

    Add `workerd: false` under `allowBuilds` in pnpm-workspace.yaml: until then pnpm 12 fails install, add and remove on workerd's build script. Refresh leaves that file as written because of how its YAML is laid out.
    

    As written, pnpm still exits 1, as the warning says. patchy dev still runs the handler in workerd. After I added workerd: false, by hand, the next refresh left the file alone with warnings: [], all four commands exit 0, and minimumReleaseAge reads 2880.

  • Pull: passed. I published a version whose snapshot has no pnpm-workspace.yaml and ran patchy pull into a new folder (exit 0, setUp: true). The pulled repo has the entry, all four commands exit 0, and the handler runs in workerd.

Extra probes
  • Tier 1 init writes the entry too. With no workerd in the tree, forced install, add and remove still exit 0.
  • dangerouslyAllowAllBuilds: true gains the entry, but pnpm still runs workerd's script, so the repo's allow-all choice stands. Legacy ignoredBuiltDependencies: [workerd] and onlyBuiltDependencies: [esbuild] gain the entry, and forced install exits 0.
  • CRLF files keep CRLF. {esbuild: true} and { esbuild: true, } take the entry inline. allowBuilds: with a comment on the key line takes it below. workerd-foo and Workerd are not mistaken for a choice. An allowBuilds sequence gets the warning.
  • allowBuilds: / workerd: with no value is kept. pnpm refuses that file at config load either way, so refresh is right to leave it.
  • vitest run src/workerdBuild.test.ts: 35 passed.

Golden journeys

  • None of them is directly touched: the diff is in the CLI's generation step, toolchain inspection and docs. Next to them, publishing a tier 2 repo version and pulling it both passed, as above.

Rollback answers: they match the diff. A revert leaves allowBuilds: workerd: false in repos. On main, the CLI never reads pnpm-workspace.yaml, and its install passes --ignore-workspace. A 0.13.0 CLI refreshed repos that already had the file, with workerd: true and with the flow layout, without trouble. There are no migrations and no packages/api or apps/infra changes, so no one-way label is needed.

Not run

  • pnpm 11, and macOS or Windows by hand: only pnpm 12.9.1 on Linux here. CI's install (macos) and install (windows) passed on this head.
  • pnpm verify: CI covers it. On this head, every check had passed except pidgeon-suite and test (22), which were still running when this was posted.

Notes

  • Only refresh gives the warning for a file it leaves alone. In such a repo, pnpm 12's install before each pnpm patchy … command prints ERR_PNPM_IGNORED_BUILDS and "The install that runs before scripts failed". pnpm patchy dev --json still exits 0, but its warnings are []. An agent that missed the refresh warning sees pnpm's raw error with no Patchy hint. That matches the PR's stated scope; it's worth knowing for Upgrading an old patch: what refresh and publish don't tell an agent #1163's agents.
  • Nit: a UTF-8 BOM at the start of an otherwise plain file (minimumReleaseAge: 1440) counts as an unusual layout. It gets the warning instead of the edit. That's safe, but Windows editors sometimes add one.

@allisonmahmood
allisonmahmood force-pushed the fix/workerd-builds-1170 branch from 23649c2 to ad7c649 Compare November 4, 2026 03:17
@allisonmahmood
allisonmahmood merged commit d3da458 into main Nov 4, 2026
24 checks passed
@allisonmahmood
allisonmahmood deleted the fix/workerd-builds-1170 branch November 4, 2026 03:29
allisonmahmood added a commit that referenced this pull request Nov 4, 2026
…ges publish (#1241)

## What changed

This adds release 36's What's new entry, written from `1acc968`. It
covers everything merged since release 35's `through` (`dd0e2ec`), and
sets the `patchy` release to `0.36.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| Improved: shortcuts work where you use them (keys for one part of a
patch, the closest wins, text boxes keep their typing keys) | #1231 |
| Improved: the shortcuts sheet shows what works where you are (Ctrl+/
and ⌘/ open it, its commands run, it opens from a patch's menu and in
view on a narrow screen, keeps the look, spells keys out away from a
Mac) | #1231, #1181, #1178, #1180, #1177 |
| Fixed: keys pressed while a patch opens reach it | #1183 |
| Fixed: pages styled with Tailwind 4 publish, and a look with the same
rule saves | #1191 |
| Fixed: an old copy of a patch no longer replaces newer work
(**Breaking** for such a copy: it needs `patchy pull` or one
`--allow-behind` publish) | #1179 |
| Improved: your agent can check a publish before sending it | #1188 |
| Improved: your agent hears what changed when it updates a patch |
#1186, #1185 |
| Fixed: your agent stops chasing false alarms (`pnpm install` exit
codes, `manifest.json` bytes, the description notice, a copied dev
record) | #1176, #1174, #1175 |
| Behind the scenes: fuller hotkeys instructions for agents; fewer
redraw costs for patches with many shortcuts | #1182, #1187 |

`patchChanges` has three sentences for the agent refreshing a patch
across this release:
- #1231's, from its PR: text fields keep their keys, `preventDefault()`,
and the sheet's Mod+/ and `.hotkey-row` buttons.
- The sheet's dialog renders in `document.body`, and element-only page
rules don't reach it (#1178, #1180). Its own row lists last (#1181). The
hotkey label helpers take only valid literals (#1177).
- Publish's `unknown_base_version` (#1179).

It also rewords release 33's "Press ? to see every shortcut a patch
has". That was true only for a patch that mounts the shortcuts sheet, so
it now says a patch *can* list its shortcuts.

The rest get no line:
- #1206, #1207, #1209 and #1220 are `pnpm dev eval` tooling.
- #1222 is release 35's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`, and release 33's reworded line.
- **Rollback safety, from the live commit `d28fdd0` (release 35) to
`1acc968`:**
- #1191 is labelled `one-way`. Its Release impact: a company look
published after this release with a nested `@supports` condition stays
stored after a revert. Release 35 refuses any bundle carrying it, so
repo publishes in that company would fail until an admin runs `patchy
look restore` to an earlier revision. Pages and Tailwind 4 repos already
published stay published.
- #1183 is the only change to what the server serves browsers: the
shell's script, under a digest-named URL. Its revert leaves nothing
behind.
- The hotkeys PRs change `patchy/hotkeys`, which patches bundle when
they are built. Published patches keep their copy.
- The CLI PRs change what a CLI writes and refuses. Release 35 reads
everything they leave behind: #1176's `allowBuilds` entry, #1174's
indented `manifest.json`, and the `version` recorded by an
`--allow-behind` publish.

**Rollback line:** If this release misbehaves, roll back to `d28fdd0`
(release 35). First check that no company's look has a nested
`@supports` condition, and `patchy look restore` an earlier revision
where one does (#1191).

## How it was verified

- **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and
`schemas.test.ts` pass (22 tests), and `bun fmt` passes on the changed
files.
- **Facts.** The sheet's new `document.body` home and its element-rule
reset were checked against `hotkeys.ts` and `hotkeySheet.ts` on main.
- **Deploy state.** I pinned the live commit from `/healthz/deep`:
`d28fdd0` (release 35). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Text and version numbers only. Like every release, the `0.36.0` bump
tells CLIs and patch repos installed before this deploy to upgrade.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm exits 1 in patch repos because workerd's build script is ignored

1 participant