-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
yarn doesn't use .npmrc from $HOME when run as root #3920
Comments
It looks like it doesn't use |
Thanks for reporting. Anyone willing to submit a PR for this? |
@kaylieEB still working on this? |
@kaylieEB no worries, just wanted to make sure to avoid duplicate work :) |
**Summary** Fix for #3920. In this [commit](https://github.com/wtgtybhertgeghgtwtg/yarn/commit/f4fe7431ed992862a1c1d2357e6521c268bad7a7), `userHome` for linux users running as root was changed to `/usr/local/share`, mainly to allow for other users to run globally added bins. However this introduced a bug where npmrc wasn't being looked in the root directory after checking `/user/local/share`. So this change pushes another location to check in case `userHome` is different from native home directory returned by `os.homedir()` **Test plan** I've added a test to generally test the `getPossibleConfigLocations` method, but I haven't been able to properly mock out running it as a root user on linux. Suggestions welcome!
We also had this problem, and we were able to solve it by placing the |
Oh, looks like we forgot to close this. This is fixed on master. |
Do you want to request a feature or report a bug?
Bug; incompatibility with npm.
What is the current behavior?
When run as the
root
user on Linux, yarn does not use$HOME/.npmrc
but uses/usr/local/share/.npmrc
instead.If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/yarnpkg/yarn/blob/v0.28.2/src/util/user-home-dir.js#L8
https://github.com/yarnpkg/yarn/blob/v0.28.2/src/registries/npm-registry.js#L132
Run
yarn config list --verbose
as root on Linux (while not in any subdirectory of$HOME
) and observe that yarn looks for.npmrc
first in the current directory, then in/usr/local/share/
, but never in$HOME
(/root
).What is the expected behavior?
Yarn defaults to
$HOME/.npmrc
as documented by npm.A module named
user-home-dir
doesn't export a string which isn't the user's home directory.Please mention your node.js, yarn and operating system version.
yarn v0.27.5
node v8.1.3
The text was updated successfully, but these errors were encountered: