Yarn Berry is detected after Yarn Classic is installed, so Berry projects fail at yarn --version --loglevel notice

Offen
#996 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
74/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
go, node.js
Bereich
build-system

Rechercherichtung

Start in src/nodejs/supply/supply.go, tracing the order of Run(), ReadPackageJSON(), and the UsesYarnBerry check. Find the existing unit-test setup for Yarn installation and add a case with .yarnrc.yml that verifies InstallYarnBerry() is called, not InstallYarn(); run the relevant Go tests. Done means Berry is selected before installation for Berry projects.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What happened

A Yarn 4 project (yarn.lock, .yarnrc.yml with yarnPath, and packageManager: [email protected]) fails during supply on v1.9.6. The buildpack installs Yarn Classic 1.22.22 instead of yarn-berry, then runs yarn --version --loglevel notice. Classic hands off to the project's Yarn 4 release through yarnPath, and Yarn 4 rejects the option:

Unknown Syntax Error: Unsupported option name ("--loglevel").
Cause

In src/nodejs/supply/supply.go, Run() chooses between InstallYarnBerry() and InstallYarn() based on s.UsesYarnBerry (around line 136). That flag is only set later, inside ReadPackageJSON() (called around line 158), where .yarnrc.yml is detected (around line 444). When the install choice is made, UsesYarnBerry is always false, so Berry projects always get Classic. The same ordering is on master and v1.9.7.

Removing yarnPath gets past the version check, but Build() then calls buildBerry() with Classic on PATH. Classic refuses to run because packageManager pins Yarn 4.

Suggested fix

Detect yarn.lock and .yarnrc.yml before the Yarn install step. For example, move that detection out of ReadPackageJSON() into a step that runs before the UsesYarnBerry check in Run(), or call ReadPackageJSON() before installing the package manager. A unit test where .yarnrc.yml is present should check that InstallYarnBerry() is called and InstallYarn() is not.

Environment
  • Buildpack: v1.9.6 (same code in v1.9.7 and master)
  • Stack: cflinuxfs4
  • Yarn: 4.18.1, nodeLinker: node-modules
Vorherrschende Sprache
Go
Sterne
174
Forks
390
Ø Merge
15 Std. 51 Min.
Gemergte PRs (30 T.)
21

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus cloudfoundry/nodejs-buildpack

Alle Issues in cloudfoundry/nodejs-buildpack

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.