Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass yarn calls through to allow for Corepack where available #1024

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

charlespierce
Copy link
Contributor

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 Yarn to ensure that there is a Volta-defined version of Yarn available.
  • This check means that we don't properly pass through to the Corepack yarn executable 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 Yarn in the Node directory and only show our NoProjectYarn / NoDefaultYarn errors if that isn't available.

Changes

  • Updated the logic for running Yarn to determine the appropriate failure ErrorKind but use that as the execution context, rather than failing before executing.
  • This will allow Yarn to 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 yarn with 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.

@avarun42
Copy link

avarun42 commented Mar 8, 2022

any update here?

@JanJakes JanJakes mentioned this pull request Apr 14, 2022
@therynamo
Copy link

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.

@mikeduminy
Copy link

Another consideration is that corepack can be installed globally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

volta install corepack doesn't provide corepack's yarn
4 participants