fix(config/reader): only sync registries.default to registry when workspace contributes it (#11754)

The sync introduced in #11744 unconditionally overwrote the unnormalized
registry value parsed from .npmrc with the normalized registries.default,
causing a trailing slash to appear in config.registry when the user only
configured a registry in .npmrc.

Restrict the sync to cases where pnpm-workspace.yaml actually contributes
a default registry different from what .npmrc provided.
This commit is contained in:
Zoltan Kochan
2026-05-20 01:06:52 +02:00
committed by GitHub
parent 04a2c9c610
commit ced20cbe71
2 changed files with 10 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/config.reader": patch
"pnpm": patch
---
Fix `config.registry` getting a trailing slash appended when `registry` is set in `.npmrc` and no `registries.default` is provided by `pnpm-workspace.yaml`. The sync from `registries.default` to `config.registry` introduced in #11744 now only fires when the workspace manifest actually contributes a different default.

View File

@@ -463,9 +463,10 @@ export async function getConfig (opts: {
// Sync registries.default to the top-level registry property so that
// commands like login/logout that use opts.registry pick up the default
// registry configured in pnpm-workspace.yaml.
// Only sync when registry was not explicitly set via CLI.
if (!explicitlySetKeys.has('registry')) {
// registry configured in pnpm-workspace.yaml. Only sync when the workspace
// manifest actually contributed a different default than what .npmrc provided,
// and when registry was not explicitly set via CLI.
if (!explicitlySetKeys.has('registry') && pnpmConfig.registries.default !== registriesFromNpmrc.default) {
pnpmConfig.registry = pnpmConfig.registries.default
}