Open gustafc opened 9 months ago
No response for over a week. Is there anything more I can do to help? I'm willing to provide a fix it if someone points me in the right direction, I'm not familiar with the yarn codebase.
@gustafc try yarn npm login --always-auth
. As far as I remember, yarn has a problems with merging authorization settings comes from ~/.yarnrc.yml & project .yarnrc.yml: auth settings treated like a single block (per repo), so empty 'alwaysAuth' in global config + 'alwaysAuth=true' in local config will produce empty 'alwaysAuth' in effective config for the particular repo (see yarn config
output).
@koshic Thanks, adding --always-auth
works 🌟 So I'll rename the bug so reflect that the problem is that npmAlwaysAuth
in project config is ignored.
Self-service
Describe the bug
(This is sort of a follow-up to #4341, where I tried to upgrade to yarn 3, which didn't work because it didn't use the token saved by yarn npm login.)
TL;DR:
yarn install
doesn't respectnpmAlwaysAuth
in the project-local.yarnrc.yml
. It works if you log in usingyarn npm login --always-auth
.Current situation
.npmrc
to use the above Nexus registry:.yarnrc
files in the projects;.npmrc
is sufficientThe problem
.npmrc
to.yarnrc.yml
thus:yarn npm login
which logged me in to our Nexus server, and wrote the token to~/.yarnrc.yml
as expectedyarn npm whoami
tells me I'm logged in:yarn install
fails with following output:I get the same error if I try to
yarn add
a new package.A bit of sleuthing (why can't I do
yarn install --verbose
?) has lead me to the following observations:npmRegistryServer
to use a hostname which doesn't exist,yarn install
fails withgetaddrinfo ENOTFOUND
, so it actually tries to fetch from my company's Nexus servercurl
the URLs in the access logs using the token in~/.yarnrc.yml
it works fine, so both token and URLs are correct~/.yarnrc.yml
, install fails with "No authentication configured for request", so it does actually seem to at least read the tokenThe only conclusion I can draw from this is that it doesn't use the token.
To reproduce
I couldn't figure out how to make Sherlock start a Nexus server for reproduction, so here's an old-fashioned shell script which
/tmp
with a local Nexus configured,yarn add
a package, which triggers the errorIf you change
yarn npm login
in the script toyarn npm login --always-auth
, step 4 will work.Environment
Additional context
No response