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

Adds a deprecation notice for --registry #603

Merged
merged 4 commits into from
Nov 25, 2019

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Nov 25, 2019

What's the problem this PR addresses?

The Vue CLI currently uses the --registry when running yarn install. This prevents yarn dlx to work, and thus makes it harder for us to add Vue inside our E2E battery.

How did you fix it?

Adding the --registry flag will cause a warning to appear and the option to be ignored, but won't abort the execution anymore. It would have been nice to error unless we're inside Vue CLI (like we do with Netlify or Zeit, for example), but there is no way to detect it afaik.

@juanpicado
Copy link
Contributor

Hi @arcanis , I'm curious about this and some questions

  • Which alternatives users will have?
  • What's exactly the error that stop Vue to use yarn? (I'm asking mostly for some context)

:)

@arcanis
Copy link
Member Author

arcanis commented Nov 25, 2019

To better understand the problem, consider that --registry specifies the registry to use for the command currently running - and only this one. Now what happens when you then run yarn install a second time?

Does it make sense for this second install to potentially fail because the wrong registry is set? Even more insidious, what will happen if we need to clone a git dependency to complete the initial install? Should the git dependencies own dependencies (required to run the prepack script) be also fetched using the proxy?

In essence, the problem is that --registry defines a setting for exactly one session, but in practice that's almost never what you want. So instead in the v2 there are different ways we recommend to configure a registry:

  • If you want to set the registry for your project, use a .yarnrc.yml file and define the registry using npmRegistryServer. This will guarantee that every Yarn command will use the exact same registry.

  • If you want to set the registry for the whole computer, do the same thing but put your .yarnrc.yml file inside your $HOME directory. This will ensure that it'll be used by default (unless projects override it).

  • If you want to set the registry for your shell session only, export YARN_NPM_REGISTRY_SERVER in your environment. Yarn will use it over whatever has been defined in the .yarnrc.yml files.

  • If you really, really, really want to only do this for a single command, you can still use the environment variable approach (YARN_NPM_REGISTRY_SERVER=https://... yarn install). This makes it clear that the registry setting will also affect any Yarn invocation down the road, like the git case I mentioned.

What's exactly the error that stop Vue to use yarn? (I'm asking mostly for some context)

Yarn 2 is strict regarding extraneous options. Where the v1 was tolerating and ignoring them, the v2 will refuse to execute the command (this is because we can't know if the option is meant to have an argument or not, and thus our parsing may be completely wrong).

In this case --registry was automatically added to every install, causing them to fail when running yarn dlx @vue/cli init foo. They have a fix in the pipe, but until them we can afford to simply add a warning.

@arcanis arcanis merged commit b3715f8 into master Nov 25, 2019
@arcanis arcanis deleted the mael/deprecate-registry-option branch November 25, 2019 14:53
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.

2 participants