You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Populate possibilities with [global, home] initially
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
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
The text was updated successfully, but these errors were encountered:
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.
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 fromlocal
because it read last.One solution might be as follows:
possibilities
with[global, home]
initiallycwd
, but add them in reverse order such that a file located incwd
is last in thepossibilities
arrayThat 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.
$HOME/.npmrc
setregistry=https://registry-a.com
$HOME/repo/.npmrc
setregistry=https://registry-b.com
$HOME/repo
runyarn
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
The text was updated successfully, but these errors were encountered: