Repository navigation
Resolve turbo through the root symlink so in-app updates use the newly installed version - #7312
Merged
Conversation
…y installed version The source update shim runs pnpm install and then rebuilds inside the process that built at startup. require.resolve memoizes realpaths process-wide, so after a turbo bump it returned the removed .pnpm/turbo@<old> entrypoint and the rebuild failed with MODULE_NOT_FOUND. Passing the node_modules/turbo symlink path lets the child node process resolve it fresh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/fix-turbo-module-not-found-error-thr_x8ksjp5wyd
branch
November 9, 2026 22:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
When a source checkout updates itself in the app, the
scripts/start-bb.mjsprocess stays alive. Each update runspnpm installand then rebuilds in that same process.buildRuntimeArtifactsfound turbo withrequire.resolve("turbo/bin/turbo"). Node caches that result, with symlinks already followed, for as long as the process runs, and a freshcreateRequireshares the same cache. So the process keeps handing the build the.pnpm/turbo@<version>path it saw at startup, even after updates movenode_modules/turboto a newer version.For a while this does no harm. pnpm leaves the old version's folder on disk, and the old
bin/turboscript hands off to the repo's local turbo, so builds still run the new version. pnpm deletes unused folders only oncemodules-cache-max-age(7 days) has passed since its last cleanup. When that cleanup runs during an update, the cached path points at a deleted file and the rebuild fails:In the reported case, one process had run several updates since before #7133 (Nov 5) moved turbo from 2.10.12 to 2.11.10. The update that failed (
55135d1e50 → f8893ee23c) didn't change turbo. It was the install where pnpm ran its cleanup (node_modules/.modules.yamlshowsprunedAt: Mon, 09 Nov 2026 22:26:25 GMT, the time of the failed update).What changed
scripts/start-bb.mjsnow passes<repoRoot>/node_modules/turbo/bin/turbo, the symlink path, to the build child process instead of resolving it in the long-lived process. The childnodefollows the symlink when it starts, so each build runs the turbo installed at that moment. turbo is a root devDependency, sonode_modules/turbois always present at the root. The unusedcreateRequireimport is removed.How you verified
Ran a real in-app update end to end, once with pre-fix code (control) and once with this PR (fix). Each run used a scratch clone, a local bare
origin, its own data dir and ports, andbb updates app apply --yes:2.10.12, andorigin/mainis commit B, which reverts that pin back to^2.11.10. Control is built on7d57800665; fix is built on this PR's commit.pnpm installat A,prunedAtinnode_modules/.modules.yamlwas backdated 8 days, so pnpm's own cleanup runs during the update, as it did in the reported case.- turbo 2.10.12 / + turbo 2.11.10, thenError: Cannot find module '.../.pnpm/[email protected]/node_modules/turbo/bin/turbo'and✗ Rebuilding bb … failed: Runtime build failed with exit code 1. That is the reported failure.turbo 2.11.10, bb came back up, andbb updates app statusreportedsource checkout cd48a0e87b is up to date.prunedAt, the control also succeeds. AModule._findPathtrace showed the shim reusing the cached[email protected]path on the second build; it worked because that folder still existed.pnpm start --dryrunbuilds through the new path.pnpm exec turbo run test --filter=@bb/scripts -- test/start-bb.test.mjspasses 4/4.🤖 Generated with Claude Code