From ced20cbe71cbb7bab25650a7710f5180e7916dc9 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 20 May 2026 01:06:52 +0200 Subject: [PATCH] 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. --- .changeset/config-reader-registry-sync-npmrc.md | 6 ++++++ config/reader/src/index.ts | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/config-reader-registry-sync-npmrc.md diff --git a/.changeset/config-reader-registry-sync-npmrc.md b/.changeset/config-reader-registry-sync-npmrc.md new file mode 100644 index 0000000000..4ce0d1cf77 --- /dev/null +++ b/.changeset/config-reader-registry-sync-npmrc.md @@ -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. diff --git a/config/reader/src/index.ts b/config/reader/src/index.ts index 6083ebe906..2bc79a6627 100644 --- a/config/reader/src/index.ts +++ b/config/reader/src/index.ts @@ -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 }