Repository navigation
Detect Yarn Berry before installing Yarn - #1003
Merged
Merged
Conversation
Run() picked InstallYarn vs InstallYarnBerry before ReadPackageJSON set UsesYarnBerry, so Berry projects were always given Yarn Classic and then failed on `yarn --version --loglevel notice` (#996). Extract the yarn.lock/.yarnrc.yml detection into DetectYarn() and call it before the install branch. Add DetectYarn specs and a Yarn Berry integration fixture. The fixture depends on the yarn-berry dependency being republished as .js, so its integration spec cannot pass until cloudfoundry/binary-builder#130 lands and manifest.yml is bumped.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The Yarn integration test uses ContainLines for messages separated by intervening logs, so the assertion will fail even when Berry installs successfully.
1 open issue
What changed in this PR
Fixes #996 by detecting Yarn Berry before the buildpack chooses which Yarn version to install.
Changes:
- Extracts reusable Yarn detection and runs it before package-manager installation.
- Adds unit coverage for Classic, Berry, marker-only projects, and stale-flag reset.
- Adds a minimal Berry fixture and deployment integration test.
The PR remains dependent on the corrected Yarn Berry artifact and manifest update described in the merge prerequisites.
| File | Description |
|---|---|
src/nodejs/supply/supply.go |
Detects Yarn flavor before installation and reuses detection during package parsing. |
src/nodejs/supply/supply_test.go |
Tests Yarn detection and flag reset behavior. |
src/nodejs/integration/yarn_test.go |
Adds Berry installation and deployment coverage. |
fixtures/yarn/berry/yarn.lock |
Supplies a Berry-format lockfile. |
fixtures/yarn/berry/server.js |
Provides a minimal HTTP application for deployment verification. |
fixtures/yarn/berry/package.json |
Defines the fixture application and start command. |
fixtures/yarn/berry/.yarnrc.yml |
Configures Berry to use node modules and global caching. |
Review effort: Balanced
This was referenced Dec 1, 2026
Contributor
|
@ramonskie I think you can rebase this one now |
Refactor log expectations for yarn installation. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Approval depends on confirming the separate releng manifest update from .tgz to .js and successful cached and uncached integration runs, which remain pending.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
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.

Warning
Do not merge yet. This PR depends on the
yarn-berrydependency being republished with the correct.jssuffix. Review item 1 from the code review: merge cloudfoundry/binary-builder#130 and let the dependency rebuild land before merging this, otherwise the new Yarn Berry integration spec will fail in CI.Why
Fixes #996.
Run()chose betweenInstallYarn(Classic) andInstallYarnBerrybeforeReadPackageJSON()setUsesYarnBerry, so Yarn Berry projects were always given Yarn Classic. Classic then handed off to the project's Yarn 4 release viayarnPathand rejected the Classic-only flag inyarn --version --loglevel notice, failing supply.Detection only depends on files in the app (
yarn.lock,.yarnrc.yml), so it can run much earlier.What changed
DetectYarn(), which setsUseYarnfromyarn.lockandUsesYarnBerryfrom.yarnrc.yml, and explicitly clears both when the project is not a Yarn project.DetectYarn()inRun()right afterLoadNvmrc(), before the Yarn install branch.DetectYarn()fromReadPackageJSON()instead of duplicating the twoFileExistscalls..yarnrc.ymlwithoutyarn.lock, and stale-flag reset.fixtures/yarn/berry) and spec assertingInstalled yarn (berry)andInstalling node modules (yarn.lock) [yarn berry], and that Classic was not installed.manifest.ymlis intentionally untouched; the releng bot updates theyarn-berryURI after the dependency is rebuilt.Merge dependency (review item 1)
The new Berry integration spec cannot pass on the current manifest:
manifest.ymlstill points atyarn-berry_4.18.1_linux_noarch_any-stack_a28ad591.tgz, which is rawyarn.js, not a tarball.vendor/github.com/cloudfoundry/libbuildpack/installer.go,.tar.gz/.tgzbranch), so it callsExtractTarGzand fails withgzip: invalid headerbeforeInstallYarnBerry()runs.Required order:
ExtFromPathpublishes.jsinstead of.tgz).yarn-berry; the content sha256 staysa28ad591…, only the published suffix changes.yarn-berryURI inmanifest.yml..jsartifact is in the manifest; integration should then pass.Validation
go build ./src/...go test ./src/nodejs/supply/— 140/140 specs passyarn install --immutablesucceeds and leaves the lockfile unchanged