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 }