Description
Verify latest release
- I verified that the issue exists in the latest pnpm release
pnpm version
No response
Which area(s) of pnpm are affected? (leave empty if unsure)
CLI
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
$ echo '//npm.pkg.github.com/:_authToken=${fawef}' > .npmrc
$ pnpm set //npm.pkg.github.com/:_authToken HI
WARN Issue while reading "...". Failed to replace env in config: ${fawef}
WARN Issue while reading "...". Failed to replace env in config: ${fawef}
$ rg HI .npmrc
Describe the Bug
This is not the first issue about env var resolution in .npmrc
but I believe that what I'm reporting and asking for is sufficiently different from other reports to warrant a separate issue.
In this case, the value I am trying to set also happens to be the value that has an environment variable that can't be resolved. The use case is setting an authentication in CI, but having it default to an environment variable locally. This gives us the best of both worlds: easy onboarding for local development, since the .npmrc
can be checked in to version control, and in CI we set a config value not with sed
, but through the official config API.
Expected Behavior
If the key that is being set can't be resolved, either ignore the error or emit only a warning, but still set the value.
What I find confusing as well is that the CLI currently emits a warning, while also not setting the env var. It seems to me that it should actually be emitting an error right now.
Which Node.js version are you using?
v24.3.0
Which operating systems have you used?
- macOS
- Windows
- Linux
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response