Skip to content

fix(cli): pnpm patchy refresh fails across a release change #460

Closed

Description

@allisonmahmood

After the instance's release digest changes, pnpm patchy refresh in an existing repo fails with Could not inspect the repo's installed toolchain.

Cause

Refresh moves node_modules aside to preserve the previous installation, installs the new pin, then runs the toolchain inspector, which it looks for next to the running CLI (…/node_modules/patchy/dist/toolchainChild.js). The running CLI is the old pinned copy, and its folder was just moved, so the child script isn't there (Cannot find module …/toolchainChild.js).

Repro: change the instance's packed release (restarting pnpm dev after any change bundled into the package is enough), then run pnpm patchy refresh in any repo pinned to the previous release.

Running the same refresh with the global patchy works, because that CLI doesn't live inside the repo's node_modules.

Both demo-prep build agents hit this independently on 2026-10-01. Related: #459 (pnpm lockfile integrity), which hits the same refresh path.

Activity

  1. added
    bug
    area:cli
    on Oct 1, 2026
  2. allisonmahmood commented on Oct 2, 2026

    @allisonmahmood
    OwnerAuthor

    This was generated by AI during triage.

    Agent Brief

    Category: bug
    Summary: After the release changes, refresh (and add/remove) run from a repo's own pnpm patchy must check the toolchain with the newly installed release.

    Current behavior:
    Reproduced on a local pnpm dev up instance. Make a repo with patchy init, change the instance's packed release (its digest moved from 464c6b… to e428e4…), then run pnpm patchy refresh in the repo. It exits 1 with Could not inspect the repo's installed toolchain. Rollback is clean: the old pin and old node_modules come back. The global patchy refresh succeeds on the same repo.

    Cause: the repo-local CLI runs from the pnpm package folder named after the old release digest. Refresh moves node_modules aside, installs the new pin, then starts the toolchain inspector subprocess (runToolchain with { inspect }). It finds toolchainChild.js next to the running CLI, and that folder no longer exists. The generate step does not break because runInstalledGenerate already runs the newly installed node_modules/patchy/dist/index.js.

    This blocks #416. Every deploy changes the release digest. The repo's AGENTS.md and the global patchy skill both tell agents to run pnpm patchy refresh inside a patch repo. add and remove go through the same refresh path, so after a deploy all three commands fail in every existing repo.

    Desired behavior:
    After refresh has installed the release, the toolchain check runs with the installed release's toolchainChild, not the running CLI's. This follows the existing rule that the installed release owns config execution and chooses the engine pin. The check gives the same result and warnings no matter which CLI started the refresh: the global patchy, the repo's pnpm patchy, or the workspace CLI the tests use.

    After an install, refresh must not load any file from the running CLI's package folder. Today the toolchain inspector is the only such file.

    Key interfaces:

    • runToolchain in the CLI's toolchain process module: today it always finds the child next to import.meta.url. Refresh needs to point it at the installed release's dist/toolchainChild.js under the repo's node_modules/patchy, the same way runInstalledGenerate finds the installed dist/index.js. Builds and publishes keep finding the child next to the running CLI.
    • The inspect <toolchain json> argv and the stdout JSON reply are a private protocol between two CLI versions, just like __generate. Keep it unchanged.

    Acceptance criteria:

    • A test runs refresh with the repo's installed CLI (node <repo>/node_modules/patchy/dist/index.js refresh --json) across a change in release digest. It exits 0, reports changed.pin: true and leaves the new pin in package.json. The existing refresh tests only run the workspace CLI, which lives outside the repo, so they never hit this.
    • The same refresh with the workspace CLI still passes, and its toolchain warnings are unchanged.
    • pnpm patchy refresh in a pnpm dev up workspace repo succeeds after a restart that changes the packed release.
    • A failed refresh still rolls back the pin, lockfile and node_modules as before.

    Out of scope:

  3. added
    ready-for-agent
    on Oct 2, 2026
  4. added 3 commits that reference this issue on Oct 2, 2026
    745c311
    2c5cc4b
    179e534
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions