Skip to content

fix: Use a pnpm preinstall script to fix catch-22 in next binary creation#91016

Merged
bgw merged 4 commits intocanaryfrom
bgw/preinstall-stub-binary
Mar 10, 2026
Merged

fix: Use a pnpm preinstall script to fix catch-22 in next binary creation#91016
bgw merged 4 commits intocanaryfrom
bgw/preinstall-stub-binary

Conversation

@bgw
Copy link
Member

@bgw bgw commented Mar 7, 2026

We've had a longstanding issue where you'd have to run pnpm i twice on a fresh checkout because pnpm wouldn't set up binary symlinks until after the binary exists, but the binary wouldn't exist until after pnpm build was done:

https://github.com/vercel/next.js/blob/canary/.github/workflows/build_reusable.yml#L303-L311

This solves that problem using a pnpm preinstall script that creates stub binaries for these files if they don't exist yet (because we haven't run pnpm build).

Test Plan

git clean -fxd
pnpm i
pnpm build
pnpm test-start test/e2e/app-dir/next-image/
pnpm test-start-turbo test/e2e/app-dir/next-image/

I tested this both locally and inside of a fresh ubuntu VM.

Running pnpm next after pnpm i but before pnpm build gives a helpful error message:

Screenshot 2026-03-06 at 9 37 14 PM

@nextjs-bot nextjs-bot added the created-by: Turbopack team PRs by the Turbopack team. label Mar 7, 2026
Copy link
Member Author

bgw commented Mar 7, 2026

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

@bgw bgw requested review from eps1lon, ijjk and ztanner March 7, 2026 05:31
@bgw bgw marked this pull request as ready for review March 7, 2026 05:51
@mondyzzz-glitch

This comment was marked as spam.

Comment on lines +66 to +67
'--lockfile=false',
'--ignore-workspace',
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why, and codex wasn't able to figure it out either, but when I was running pnpm i inside of a fresh ubuntu VM, it was trying to modify the pnpm-lock.yaml unless these flags were set due to some sort of workspace isolation issue.

But either way, these flags seem like a small improvement here.

@bgw bgw requested a review from a team March 10, 2026 04:37
@bgw bgw merged commit 1eab336 into canary Mar 10, 2026
288 of 292 checks passed
@bgw bgw deleted the bgw/preinstall-stub-binary branch March 10, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Turbopack team PRs by the Turbopack team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants