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

Config files possibly read multiple times and in inconsistent order #949

Closed
jgoz opened this issue Oct 12, 2016 · 2 comments
Closed

Config files possibly read multiple times and in inconsistent order #949

jgoz opened this issue Oct 12, 2016 · 2 comments

Comments

@jgoz
Copy link
Contributor

jgoz commented Oct 12, 2016

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

If cwd is a subdirectory of $HOME, .npmrc and .yarnrc files will be read multiple times and in the wrong order.

This is because of these lines. Before that block, possibilities will be [global, home, local]. But after that block, possibilities will be [global, home, local, local, ..., home, ...] with possibilites from intermediate directories (if any).

This is incorrect. Not only will the config files be read multiple times, but values from home will override those from local because it read last.

One solution might be as follows:

  1. Populate possibilities with [global, home] initially
  2. Look for local files starting with cwd, but add them in reverse order such that a file located in cwd is last in the possibilities array
  3. Only add a config file if it is not already contained in the array

That way we avoid unnecessary reading/parsing and the values have the correct precedence.

If the current behavior is a bug, please provide the steps to reproduce.

  • In $HOME/.npmrc set registry=https://registry-a.com
  • In $HOME/repo/.npmrc set registry=https://registry-b.com
  • In $HOME/repo run yarn

Requests will be pulled from https://registry-a.com.

What is the expected behavior?

Requests should be pulled from https://registry-b.com.

Please mention your node.js, yarn and operating system version.
Node: v4.6.0
Yarn: master
OS: Windows 10 x64

@busches
Copy link
Contributor

busches commented Dec 1, 2016

Can you reproduce this with yarn@latest? I'm not able to recreate the issue using the latest Yarn v0.17.10 using the steps you provided. Yarn correctly pulls from https://registry-b.com. Running yarn config get registry does return https://registry.yarnpkg.com which seems like a different issue.

@jgoz
Copy link
Contributor Author

jgoz commented Dec 1, 2016

@busches I believe this was fixed in #951 but this issue was left open by mistake. Closing it now.

@jgoz jgoz closed this as completed Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@jgoz @sebmck @busches and others