Skip to content

fix: use pnpm rebuild to wire docs-toolkit bin under pnpm v11#7346

Merged
yomybaby merged 1 commit into
mainfrom
05-11-fix_use_pnpm_rebuild_to_wire_docs-toolkit_bin_under_pnpm_v11
May 11, 2026
Merged

fix: use pnpm rebuild to wire docs-toolkit bin under pnpm v11#7346
yomybaby merged 1 commit into
mainfrom
05-11-fix_use_pnpm_rebuild_to_wire_docs-toolkit_bin_under_pnpm_v11

Conversation

@yomybaby
Copy link
Copy Markdown
Member

@yomybaby yomybaby commented May 11, 2026

Follow-up to #7342. The previous fix dropped a stale pnpm@10 pin in amplify.yml but the Amplify docs build kept failing with the same error:

# Executing command: pnpm --filter backend.ai-webui-docs exec docs-toolkit build:web --lang all --no-strict
undefined
[ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL] Command "docs-toolkit" not found

Root cause (verified locally)

backend.ai-docs-toolkit exposes its CLI via package.json#bin.docs-toolkit → ./dist/cli.js, but dist/cli.js only exists after tsc runs. The existing amplify.yml flow tried to work around the chicken-and-egg by running install twice around the toolkit build:

- pnpm install --frozen-lockfile          # 1st: dist/ empty → bin link skipped with warning
- pnpm --filter backend.ai-docs-toolkit run build   # populates dist/cli.js
- pnpm install --frozen-lockfile          # 2nd: hoping pnpm wires the bin link

Reproducing on a clean git clone of main HEAD with pnpm v11.0.8:

[WARN] Failed to create bin at .../node_modules/.bin/docs-toolkit.
       ENOENT: no such file or directory, open '.../backend.ai-docs-toolkit/dist/cli.js'
...
$ pnpm install --frozen-lockfile           # 2nd run
Scope: all 8 workspace projects
Already up to date
Done in 113ms using pnpm v11.0.8
$ pnpm --filter backend.ai-webui-docs exec docs-toolkit --help
undefined
[ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL] Command "docs-toolkit" not found

In pnpm v11, the second install sees the lockfile already satisfied and exits in ~100 ms without re-running bin link creation. The first install's warning-skipped link stays broken. --force does not help (it still short-circuits on the satisfied lockfile). The v10→v11 bump in #7307 silently regressed this dance — v10 was apparently lenient here.

Fix

Replace the second pnpm install --frozen-lockfile with pnpm rebuild, which is the documented mechanism for re-running link creation against the current node_modules. After this:

$ pnpm rebuild
$ ls node_modules/.bin/docs-toolkit
-rwxr-xr-x  1 codejong  wheel  802 ... node_modules/.bin/docs-toolkit
$ pnpm --filter backend.ai-webui-docs exec docs-toolkit build:web --lang all --no-strict
[next/en] Done: 29 pages generated (2.1s)
[next/ko] Done: 29 pages generated (2.1s)
[next/ja] Done: 29 pages generated (2.1s)
[next/th] Done: 29 pages generated (2.1s)
Website generated at: .../dist/web

dist/web/ contains index.html, next/, assets/, robots.txt, etc. — exactly the artifact Amplify expects.

Why not just bake it into a postinstall

A prepare / postinstall on backend.ai-docs-toolkit would invoke tsc for every consumer, including local dev. Keeping the build orchestration in the deployment manifest is consistent with how the package.yml / docs-archive workflows already do it (the inline comment in amplify.yml cross-references those). Only the second install was load-bearing for bin linking, and pnpm rebuild is the smaller, more honest tool for that job.

Amplify docs build was still failing with `Command "docs-toolkit" not
found` even after #7342 dropped the stale pnpm@10 pin, because pnpm v11
treats a second `pnpm install --frozen-lockfile` against an already-
satisfied lockfile as a no-op (~100ms `Already up to date`) and does
NOT revisit bin link creation. The toolkit's `dist/cli.js` is generated
between the two installs, so the second install is the only chance to
turn the warning-skipped bin link into a real one — and v11 skips it.

`pnpm rebuild` is the contract for "re-run link creation against the
current node_modules layout" and works on both v10 and v11. Reproduced
the failure and the fix locally against a clean clone of main HEAD:

  cd packages/backend.ai-webui-docs
  pnpm install --frozen-lockfile          # warns: dist/cli.js missing
  pnpm --filter backend.ai-docs-toolkit run build
  pnpm rebuild                            # wires .bin/docs-toolkit
  pnpm --filter backend.ai-webui-docs exec docs-toolkit build:web \
    --lang all --no-strict                # succeeds, writes dist/web/
Copy link
Copy Markdown
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the size:S 10~30 LoC label May 11, 2026
@yomybaby yomybaby marked this pull request as ready for review May 11, 2026 14:22
Copilot AI review requested due to automatic review settings May 11, 2026 14:22
@yomybaby yomybaby merged commit 47f1b74 into main May 11, 2026
13 checks passed
@yomybaby yomybaby deleted the 05-11-fix_use_pnpm_rebuild_to_wire_docs-toolkit_bin_under_pnpm_v11 branch May 11, 2026 14:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the AWS Amplify build configuration for the docs site to correctly (re)create the docs-toolkit CLI bin link under pnpm v11 after the toolkit has been built, preventing pnpm exec docs-toolkit ... from failing in the later build phase.

Changes:

  • Refines the preBuild rationale/commentary around pnpm v11 bin-link behavior for backend.ai-docs-toolkit.
  • Replaces the second pnpm install --frozen-lockfile with pnpm rebuild to trigger bin-link (re)wiring after dist/ is produced.

Comment thread amplify.yml
Comment on lines +137 to +147
# Subtle pnpm-v11 behavior: a second `pnpm install
# --frozen-lockfile` here is a no-op (`Already up to date`,
# ~100ms) because the lockfile is already satisfied — it
# does NOT revisit bin links. `pnpm rebuild` is what
# actually re-runs link creation against the now-populated
# `dist/`. Without this the later `pnpm exec docs-toolkit`
# call fails with `[ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL]
# Command "docs-toolkit" not found`. (Same chicken-and-egg
# pattern as FR-2719's build_docs job in package.yml and
# the docs-archive workflow; the v10→v11 bump in #7307
# silently regressed the old install/build/install dance.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10~30 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants