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

[BUG] npm config does not allow path types to use ${ENVIRONMENT_VARIABLE} syntax. #5267

Closed
2 tasks done
alasdairhurst opened this issue Aug 5, 2022 · 2 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@alasdairhurst
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I'm trying to configure a project using the command line by setting a custom registry and CA file. The project will be built in a docker container, so all configuration should be configured relative to the project, and nothing from the host should be referenced.

Since npm automatically turns the relative paths into absolute paths when setting cafile, let's try an use an environment variable as documented here: https://docs.npmjs.com/cli/v7/configuring-npm/npmrc

npm config set cafile='\${PWD}/cafile.crt' --location=project

This results in the bug:

cafile=/absolute/path/to/project/${PWD}/cafile.crt

This is also an issue without setting location

Expected Behavior

I expect

npm config set cafile='\${PWD}/cafile.crt'

To write:

cafile=${PWD}/cafile.crt

Steps To Reproduce

  1. run npm config set cafile='\${PWD}/cafile.crt'
  2. see that unexpected data is written to .npmrc

Environment

  • npm: 8.16.0
  • Node.js: 16.14.2
  • OS Name: MacOS Big Sur
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here
@alasdairhurst alasdairhurst added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 5, 2022
@wraithgar wraithgar added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Aug 11, 2022
@wraithgar wraithgar changed the title [BUG] "npm config set cafile" changes absolute paths specified with environment variables [BUG] npm config does not allow path types to use ${ENVIRONMENT_VARIABLE} syntax. Aug 11, 2022
@wraithgar
Copy link
Member

wraithgar commented Aug 11, 2022

This affects all config items with a path type

~/D/n/cli (gar/exec-directory|✔) $ node . config set cache "\${PWD}/.cache"
~/D/n/cli (gar/exec-directory|✔) $ grep cache ~/.npmrc
cache=/Users/wraithgar/Development/npm/cli/${PWD}/.cache

@wraithgar
Copy link
Member

Fixed by #6328

~ $ npm config set cache "\${PWD}/.cache"
~ $ grep cache ~/.npmrc
cache=${PWD}/.cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants