Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Work around a weird bug in Yarn v1.x
Certain repositories need node-gyp in order to build their native C/C++ dependencies. Yarn has some mechanism to detect this. I believe the ppm repo is detected as one of these special repos. This detection happens during the 'yarn install' command's package lifecyle script handling code, by the way. This is important later. Yarn also has logic to detect if node-gyp is globally available on the system, in the form of a specific 'bin/node-gyp-bin' subdirectory of the npm package. Well, npm as of version 9.7.2 and newer has deleted this 'bin/node-gyp-bin' sub-directory. (NodeJS 18.18.0 and newer, as well as NodeJS 20.4.0 and newer, bundle new enough npm to be affected by this change.) Okay, so we are now two layers deep into edge cases. You're still following along okay, I hope? In this double edge case, Yarn installs its own copy of node-gyp, in a Yarn-specific global packages dir. This works, in and of itself, but after it installs this copy of node-gyp, Yarn doesn't properly hand back off to the rest of its package lifecycle script handler. So, we are left with a mostly successful repo install, minus this repo's all-important postinstall lifecycle script ever running. Yeah, this bug breaks ppm repo. It's easy to work around IRL: Just run 'yarn install' again, or run 'yarn postinstall'. The copy of node-gyp Yarn successfully globally installed means this is a one-time issue only for IRL machines. Ths real problem is in CI, where every runner is spun up fresh or each CI run. We need a proper workaround for CI. Hence this commit. So here we are. A comically complex chain of events in the NodeJS ecosystem (and to be fair, the non-maintenance for bug-fixes of Yarn v1.x) have lead to a skipped postinstall script in our ppm repo (and presumably in certain other repos), if using Yarn v1.x with npm 9.7.2 or newer installed as the global copy of npm. (As opposed to with an older version of npm being the globally installed copy of npm, which still works fine.) This breaks the repo. This commit works around it. But we should probably switch to Yarn 2.x or newer, AKA "Yarn Berry", soon if we can.
- Loading branch information