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

.npmrc content doesn't always pass legacyRegex validation on Windows #29

Open
exaucae opened this issue Jan 21, 2022 · 3 comments
Open

Comments

@exaucae
Copy link

exaucae commented Jan 21, 2022

The .npmrc at the root of my project does not pass the legacyRegex validation although it should.

>npx google-artifactregistry-auth --credential-config=./.npmrc
Retrieving application default credentials...
Success!
${home}\AppData\Local\npm-cache\_npx\64aef35f3ba01c7c\node_modules\google-artifactregistry-auth\src\update.js:131
    throw new Error(
          ^

Error: Artifact Registry config not found in ${path}\.npmrc
Run `gcloud beta artifacts print-settings npm`.
    at updateConfigFile (${home}\AppData\Local\npm-cache\_npx\64aef35f3ba01c7c\node_modules\google-artifactregistry-auth\src\update.js:131:11)

Is there anything I am missing?

Find relevant config below:
.npmrc


@scope:registry=https://my-registry
//a-region-npm.pkg.dev/project/repo/:_password="foo"
//a-region-npm.pkg.dev/project/repo/:username=oauth2accesstoken
//a-region-npm.pkg.dev/project/repo/:email=radom@email.com
//a-region-npm.pkg.dev/project/repo/:always-auth=true


OS Name:                   Microsoft Windows 10 Professionnel
OS Version:                10.0.19043 N/A Build 19043
NPM                           7.20.3
NODE                         v16.6.2

Google Cloud SDK 368.0.0
beta 2022.01.07
bq 2.0.72
core 2022.01.07
gsutil 5.6

legacy-regex

One key point is that I have several projects wherein some have the setup correct, while others just fail before working later on with the same .npmrc.

I am updating the issue title based on that.

@exaucae exaucae changed the title Credentials not written in .npmrc on Windows .npmrc content doesn't always pass legacyRegex validation on Windows Jan 21, 2022
@yihanzhen
Copy link
Member

Hi @exaucae

I can't repro the issue with the sample input you have above, in which case the plugin found the match and updated the token successfully.

You changed the title to "it doesn't always work", do you have a sample input where the plugin fails to update consistently, or is the failure intermittent even with the same input?

@exaucae
Copy link
Author

exaucae commented Jan 27, 2022

It's intermitent with the same input @yihanzhen.

@exaucae
Copy link
Author

exaucae commented Jan 27, 2022

Update
Removing the @scope allows .npmrc to be updated:

- @scope:registry=https://my-registry
+ registry=https://my-registry
//a-region-npm.pkg.dev/project/repo/:_password="foo"
//a-region-npm.pkg.dev/project/repo/:username=oauth2accesstoken
//a-region-npm.pkg.dev/project/repo/:email=radom@email.com
//a-region-npm.pkg.dev/project/repo/:always-auth=true

But then no other public package can be downloaded: the package manager now points to the private registry.

So the hack for now is to:

  • first remove the scope
  • then run npx google-artifactregistry-auth
  • finally reset the scope

Would appreciate any insight about this.

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

No branches or pull requests

2 participants