Skip to content

fix: Handle Yarn 2+ in @turbo/codemod install commands#12477

Merged
anthonyshew merged 1 commit intomainfrom
shew/investigate-8567
Mar 28, 2026
Merged

fix: Handle Yarn 2+ in @turbo/codemod install commands#12477
anthonyshew merged 1 commit intomainfrom
shew/investigate-8567

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

Summary

Closes #8567

  • getGlobalUpgradeCommand() now returns undefined for Yarn 2+ (Berry removed yarn global), causing the orchestrator to fall through to the correct local install path
  • The CLI notify-update suggestion now detects Yarn version and suggests yarn dlx @turbo/codemod for Berry users instead of the invalid yarn global add
  • Added Yarn 4.x test coverage to both local and global install command tests

Why

Yarn 2+ removed yarn global entirely. The codemod was generating invalid install commands for any Yarn Berry project, breaking the final migration step. The local install path already handled Berry correctly via an gte("2.0.0") semver check, so the fix lets Berry users naturally reach that path when global install isn't possible.

Testing

get-turbo-upgrade-command.test.ts covers all combinations of Yarn 1.x, 2.x, 3.x, and 4.x for both local and global install scenarios. The Yarn 2+/3+ global test cases now verify the fallthrough-to-local behavior instead of asserting the broken yarn global add output.

Yarn 2+ (Berry) removed `yarn global`, so `getGlobalUpgradeCommand()`
now returns undefined for Yarn 2+ and falls through to local install.
Also fixes the CLI notify-update suggestion for Yarn Berry users.
@anthonyshew anthonyshew requested a review from a team as a code owner March 28, 2026 16:24
@anthonyshew anthonyshew requested review from tknickman and removed request for a team March 28, 2026 16:24
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
examples-kitchensink-blog Building Building Preview, Open in v0 Mar 28, 2026 4:24pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
turbo-site Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Mar 28, 2026 4:24pm

@anthonyshew anthonyshew merged commit 64e5ffd into main Mar 28, 2026
46 checks passed
@anthonyshew anthonyshew deleted the shew/investigate-8567 branch March 28, 2026 16:50
github-actions Bot added a commit that referenced this pull request Mar 28, 2026
## Release v2.8.22-canary.2

Versioned docs: https://v2-8-22-canary-2.turborepo.dev

### Changes

- release(turborepo): 2.8.22-canary.1 (#12473) (`f929b6d`)
- fix: Handle Yarn 2+ in @turbo/codemod install commands (#12477)
(`64e5ffd`)

Co-authored-by: Turbobot <turbobot@vercel.com>
github-actions Bot added a commit that referenced this pull request Mar 30, 2026
## Release v2.9.0

Versioned docs: https://v2-9-0.turborepo.dev

### Changes

- release(turborepo): 2.8.21 (#12472) (`be8dc50`)
- fix: Avoid panic for unanchorable/non-UTF8 git paths (#11106)
(`5f45fdb`)
- release(turborepo): 2.8.22-canary.1 (#12473) (`f929b6d`)
- fix: Handle Yarn 2+ in @turbo/codemod install commands (#12477)
(`64e5ffd`)
- release(turborepo): 2.8.22-canary.2 (#12479) (`be8cf64`)
- feat: Accept `experimentalCI` key in turbo.json task config (#12480)
(`bff5591`)
- release(turborepo): 2.8.22-canary.3 (#12481) (`cd2d25b`)
- fix: Prevent pnpm overrides from corrupting resolved peer-dep variants
(#12482) (`91d31cf`)
- release(turborepo): 2.8.22-canary.4 (#12483) (`a6eabc6`)
- fix: Skip writing unchanged files during slow-path cache restore
(#12484) (`b7c0001`)
- release(turborepo): 2.8.22-canary.5 (#12486) (`3155a35`)
- fix: Replace pre-existing symlinks with directories during cache
restore (#12488) (`d07bee8`)
- release(turborepo): 2.8.22-canary.6 (#12490) (`5e9ba83`)
- fix: Follow symlinks during workspace package discovery (#12489)
(`f39b370`)
- release(turborepo): 2.8.22-canary.7 (#12491) (`c03cc5f`)
- fix: Reduce inotify watch count via gitignore-aware directory walking
on Linux (#12398) (`664fd88`)
- release(turborepo): 2.8.22-canary.8 (#12492) (`841fe79`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@turbo/codemod does not handle Yarn 4 installations

1 participant