GoogleCloudPlatform/artifact-registry-npm-tools

Path problem 🤔

AkselAllas opened this issue · 3 comments

On MacOS:

npm run artifactregistry-login

> /Users/akselallas/dev/demo
> artifactregistry-auth --repo-config=[~/.npmrc] --credential-config=[~/.npmrc]

Retrieving application default credentials...
Success!
(node:52218) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/Users/akselallas/dev/demo/[~/.npmrc]'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52218) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:52218) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Alternate run without ~

yarn npm-auth
yarn run v1.22.18
$ ./node_modules/.bin/artifactregistry-auth --repo-config=[./.npmrc] --credential-config=[~/.npmrc]
Retrieving application default credentials...
[Error: ENOENT: no such file or directory, open '/Users/akselallas/dev/demo/[./.npmrc]'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/akselallas/dev/demo/[./.npmrc]'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The following works ./node_modules/.bin/artifactregistry-auth --repo-config=.npmrc --credential-config=.npmrc

I solved it with a "temporary"🤞 hack

"npm-auth": "RELPATH=$(realpath --relative-to=. $HOME/.npmrc) && ./node_modules/.bin/artifactregistry-auth --repo-config=$RELPATH --credential-config=$RELPATH"

@AkselAllas I'm not sure I am understanding the question here. Relative paths should work and I just tested with ..:

artifactregistry-auth --repo-config=./.npmrc --credential-config=~/.npmrc

You shouldn't need the [ ] for --repo-config. Maybe that's why reading the repo config failed.

Maybe 🤔 Anyhow, not a problem for me anymore, so closing issue.