berry
berry copied to clipboard
fix: yarn install failed when dependency package using yarn in postin…
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:
- using yarnPath with a pre-built
yarn.js
- some of our npm package include
yarn
command in thepostinstall
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.
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:
- when calling
project.findLocatorForLocation
yarn alway pass a path with a/
ending, but thelocatorByPath
map only contains key without/
ending. - the
locator
should be a Locator struct instead of a string
i also fixed these two problem as the file changes show.
Checklist
- [x] I have read the Contributing Guide.
- [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.