volta
volta copied to clipboard
Pass yarn calls through to allow for Corepack where available
Closes #987
Info
- Node now ships with Corepack, which is an alternative way to manage your package manager using a similar shim method to Volta.
- However, we currently do a check internally when running
Yarnto ensure that there is a Volta-defined version of Yarn available. - This check means that we don't properly pass through to the Corepack
yarnexecutable in cases where Volta is managing Node but Corepack is handling Yarn. - At the same time, we already have the ability to provide a custom error message in the case that launching a tool fails.
- For better interoperability with Corepack, we should attempt to pass through to
Yarnin the Node directory and only show ourNoProjectYarn/NoDefaultYarnerrors if that isn't available.
Changes
- Updated the logic for running Yarn to determine the appropriate failure
ErrorKindbut use that as the execution context, rather than failing before executing. - This will allow
Yarnto run (using the platform PATH which includes the Node binary directory) even when Yarn isn't set in Volta. - If Corepack is available and set up, it will be called by running
yarnwith the Node binary directory. - If not, then the execution will fail and show the appropriate error message.
Notes
- Still working through the specifics of how to make the failure case work: With the Volta bin directory still on the PATH, the call will actually always succeed, even if the subsequent call ultimately fails (when it detects the recursion environment variable and tries to call out to the regular system). We need some way to pass the error kind through to that subsequent call, or otherwise detect a possible failure ahead of time.
any update here?
Would love this feature if there is still appetite for it! It would really help in setting up CI runners so we don't have to worry about yarn mirrors in the hooks.json and we can just let corepack do all of the work for us.
Another consideration is that corepack can be installed globally