fix: let Renovate link node_modules when updating lockfiles - #10311
Conversation
| "dependencyDashboardApproval": true, | ||
| "minimumReleaseAge": "3 days", | ||
| "postUpdateOptions": ["yarnDedupeHighest"], | ||
| "skipInstalls": false, |
There was a problem hiding this comment.
Can't we just disable the post-install for Renovate? There's no reason to run it.
Bit hacky, but this is how we do it in the extension:
There was a problem hiding this comment.
Where are we doing this yarn run postinstall then? 🤔
There was a problem hiding this comment.
we're not, yarn is. it's a root lifecycle script so yarn runs it itself after the Link step, that's where the yarn run ... <scriptName> in the error comes from.
and it never gets to the script body anyway. swapped it for a bare node -e "console.log('hi')" and same failure.
There was a problem hiding this comment.
So with yarn install --mode=update-lockfile, Yarn still runs postinstall, even though it isn't able to? That seems confusing.
There was a problem hiding this comment.
nah you were right to doubt it, i had it wrong. yarn doesn't run postinstall in that mode at all.
it's the lavamoat allow-scripts plugin in .yarnrc.yml. its afterAllInstalled hook shells out to yarn run allow-scripts, which needs the node_modules state file update-lockfile never writes. dropping the postinstall changes nothing, dropping the plugin makes it pass.
same fix though, skip-build runs the Link step. PR description updated.
There was a problem hiding this comment.
Right, that makes more sense.
Maybe we should add an environment variable to the allow-scripts plugin (or detect the install mode, if that's possible) so we can skip it when it's not needed instead?
I can approve this for now, but maybe look into that as follow-up.
There was a problem hiding this comment.
Maybe we should add an environment variable to the allow-scripts plugin (or detect the install mode, if that's possible) so we can skip it when it's not needed instead?
I had the same problem when using Renovate on my Prettier plugin, and this is the same idea I landed on 😄. I forgot to mention it, and haven't implemented it yet. Very easy to do though.
Explanation
Approving an update on the Dependency Dashboard (#10300) produced no pull request. Renovate built the branch, hit a
lock file error, and reportedNo files to commit. Underneath that:Renovate runs
yarn install --mode=update-lockfile, which skips the Link step, sonode_modulesand its install state file are never written. Our.yarnrc.ymlloads LavaMoat'splugin-allow-scripts, whoseafterAllInstalledhook runsyarn run allow-scripts.yarn runneeds that state file to resolve the binary, so it exits non zero, and Renovate reads that as a lock file error and throws the updated lockfile away.Isolated it by running
yarn install --mode=update-lockfilecold onmainwith each piece removed in turn:.yarnrc.ymlpluginpostinstallThe third row also shows Yarn does not run root lifecycle scripts in this mode at all, so the root
postinstallis not involved.Setting
skipInstalls: falsemakes Renovate useyarn install --mode=skip-buildinstead (source): the Link step runs, so the state file exists andallow-scriptssucceeds, while dependency build scripts stay skipped. Cold run onmain, exit 0 in 26 seconds.This also reverts #10303. The
! Corepack is about to downloadline is a notice on stderr, not a blocking prompt, and was never the cause.References
Reverts #10303. Follows #10298. Part of WPC-1161.
Checklist