berry icon indicating copy to clipboard operation
berry copied to clipboard

fix: yarn install failed when dependency package using yarn in postin…

Open benny1213 opened this issue 8 months ago • 3 comments

What's the problem this PR addresses?

when running yarn install script, there is an error occur: "xx must be built because it never has been before or the last one failed" and the postinstall script of the error package did not run correctly.

Preconditions:

  1. using yarnPath with a pre-built yarn.js
  2. some of our npm package include yarn command in the postinstall script.

you can find more detail from minimal reproducible repo

How did you fix it?

after debug, i found the linkersCustomData did not restore correctly when running the yarn in the postinstall script, which causing yarn command in postinstall script refused to run.

image

so i tried calling project.restoreInstallState() when customData is missing to try restore the customData.

after i fixed this issue, i found two little issue still showing:

  1. when calling project.findLocatorForLocation yarn alway pass a path with a / ending, but the locatorByPath map only contains key without / ending.
  2. the locator should be a Locator struct instead of a string image

i also fixed these two problem as the file changes show.

Checklist

  • [x] I have set the packages that need to be released for my changes to be effective.
  • [x] I will check that all automated PR checks pass before the PR gets reviewed.

benny1213 avatar Jun 20 '24 11:06 benny1213