Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a corepack plugin that enables Corepack to handle PNPM and Yarn version installs while using the same version of Node.js as the project.
Motivation
(largely copy-pasted from @jay-aye-see-kay's explanation on Slack)
There’s a subtle but messy issue that can arise using Devbox, Node.js, and Yarn/PNPM. If you install node and yarn as documented you will end up with two different versions of node:
This happens because nix bundles all dependencies into every package, yarn is getting it’s own copy of Node.js, which may be more recent than the Node.js version the project is using.
Corepack by default tries to install shim scripts for both
yarn
andpnpm
in the same directory thatnode
is found in. Unfortunately when using devbox, thenode
binary is in the Nix store, which is read only, so Corepack fails to set up correctly.How the plugin works works
.devbox/virtenv/pnpm_plugin/bin/
corepack enable --install-directory "./devbox/virtenv/pnpm_plugin/bin/"
, which adds thepnpm
andyarn
shim scripts./devbox/virtenv/pnpm_plugin/bin/
to thePATH
environment variable.Testing
Devbox doesn't seem to allow using a plugin from Github with a branch (it's hard-coded to "master"), but I tested this on employee-imports: https://github.com/cultureamp/employee-imports/compare/jasono/demonstrate-corepack-plugin?expand=1
It might be worth setting up the unit tests to cover our plugins, perhaps even as part of this PR
Jira card: https://cultureamp.atlassian.net/browse/FEF-879
See also issue on Devbox repo: jetify-com/devbox#1577