Skip to content

ERR_INVALID_AUTH triggered by semantic-release npm despite not having this field set in checkout directory #777

@cdaringe

Description

@cdaringe

Problem

Unable to release due to a common auth error regarding the _auth field which is not present in my config.

The associated stack:

09:32:27 [4:32:27 PM] [semantic-release] › ✘  An error occurred while running semantic-release: Error: Command failed with exit code 1: npm version 1.0.0 --userconfig /tmp/c1b619531cbf95a121902fabb9d6d9f9/.npmrc --no-git-tag-version --allow-same-version
09:32:27 npm ERR! code ERR_INVALID_AUTH
09:32:27 npm ERR! Invalid auth configuration found: `_auth` must be renamed to `//npme.foo.com/:_auth` in user config
09:32:27 npm ERR! Please run `npm config fix` to repair your configuration.`
09:32:27 
09:32:27 npm ERR! A complete log of this run can be found in: /mnt/jenkinspan/workspace/myorg/foolocale/.npm/_logs/2024-04-12T16_32_27_233Z-debug-0.log
09:32:27     at makeError (file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/error.js:60:11)
09:32:27     at handlePromise (file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js:124:26)
09:32:27     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
09:32:27     at async default (file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/@semantic-release+npm@12.0.0_semantic-release@23.0.8/node_modules/@semantic-release/npm/lib/prepare.js:26:3)
09:32:27     at async prepare (file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/@semantic-release+npm@12.0.0_semantic-release@23.0.8/node_modules/@semantic-release/npm/index.js:63:3)
09:32:27     at async validator (file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/semantic-release@23.0.8_typescript@5.4.5/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
09:32:27     at async file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/semantic-release@23.0.8_typescript@5.4.5/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
09:32:27     at async Promise.all (index 0)
09:32:27     at async next (file:///mnt/jenkinspan/workspace/myorg/foolocale/ws/node_modules/.pnpm/p-reduce@3.0.0/node_modules/p-reduce/index.js:15:44) {
09:32:27   shortMessage: 'Command failed with exit code 1: npm version 1.0.0 --userconfig /tmp/c1b619531cbf95a121902fabb9d6d9f9/.npmrc --no-git-tag-version --allow-same-version',
09:32:27   command: 'npm version 1.0.0 --userconfig /tmp/c1b619531cbf95a121902fabb9d6d9f9/.npmrc --no-git-tag-version --allow-same-version',
09:32:27   escapedCommand: 'npm version 1.0.0 --userconfig "/tmp/c1b619531cbf95a121902fabb9d6d9f9/.npmrc" --no-git-tag-version --allow-same-version',
09:32:27   exitCode: 1,

Research

Observation 1: The error claims _auth format is wrong, but my npm config has no _auth set. npm config list in my checkout in CI shows no _auth (evidence attached below).

  • my local .npmrc has only one entry (registry), nothing to do with auth
  • global prefixes globalconfig does have //npme.foo.com/:_auth=(redacted) in it. It does not have _auth!
npm config list, immediately before calling semantic release
09:32:21 + npm config list
09:32:22 ; "global" config from /mnt/jenkinspan/workspace/myorg/foolocale/tools/nix_64/nodejs-21.7.3/globalconfig
09:32:22 
09:32:22 //npme.foo.com/:_auth = (protected) 
09:32:22 email = "devtools@myorg.com" 
09:32:22 prefix = "/mnt/jenkinspan/workspace/myorg/foolocale/tools/nix_64/nodejs-21.7.3" 
09:32:22 
09:32:22 ; "project" config from /mnt/jenkinspan/workspace/myorg/foolocale/ws/.npmrc
09:32:22 
09:32:22 ; registry = "https://npme.foo.com" ; overridden by env
09:32:22 
09:32:22 ; "env" config from environment
09:32:22 
09:32:22 cache = "/mnt/jenkinspan/workspace/myorg/foolocale/.npm" 
09:32:22 registry = "https://npme.foo.com/" 
09:32:22 store-dir = "/mnt/jenkinspan/workspace/myorg/foolocale/.pnpm" 
09:32:22 userconfig = "/mnt/jenkinspan/workspace/myorg/foolocale/tools/nix_64/nodejs-21.7.3/userconfig" 
09:32:22 
09:32:22 ; node bin location = /mnt/jenkinspan/workspace/myorg/foolocale/tools/nix_64/nodejs-21.7.3/bin/node
09:32:22 ; node version = v21.7.3
09:32:22 ; npm local prefix = /mnt/jenkinspan/workspace/myorg/foolocale/ws
09:32:22 ; npm version = 10.2.4
09:32:22 ; cwd = /mnt/jenkinspan/workspace/myorg/foolocale/ws
09:32:22 ; HOME = /mnt/jenkinspan
09:32:22 ; Run `npm config ls -l` to show all defaults.

Observation 2: The command fails on npm version, per the stack trace, but the same npm version invocation works when run locally in my CI checkout, vs the /tmp/... semrel uses.

npm version 0.0.3 --userconfig ./.npmrc --no-git-tag-version --allow-same-version
09:32:22 + npm version 0.0.3 --userconfig ./.npmrc --no-git-tag-version --allow-same-version
09:32:22 
09:32:22 v0.0.3

Discussion

  • why would npm version work in CI immediately before semantic-release, but not when sem-rel does stuff off in a temp dir?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions