From 7a4b92d63584e651916fddc45829ea2c58fe075e Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Mon, 23 Jun 2025 16:26:29 +0800 Subject: [PATCH 1/3] fix: pnpm-sync causing .modules.yaml ENOENT during install, #5201 --- libraries/rush-lib/src/logic/base/BaseInstallManager.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/rush-lib/src/logic/base/BaseInstallManager.ts b/libraries/rush-lib/src/logic/base/BaseInstallManager.ts index 2bb9ec8afcf..02427c1da0f 100644 --- a/libraries/rush-lib/src/logic/base/BaseInstallManager.ts +++ b/libraries/rush-lib/src/logic/base/BaseInstallManager.ts @@ -293,11 +293,12 @@ export abstract class BaseInstallManager { if (this.rushConfiguration.isPnpm && experiments?.usePnpmSyncForInjectedDependencies) { const pnpmLockfilePath: string = subspace.getTempShrinkwrapFilename(); const dotPnpmFolder: string = `${subspace.getSubspaceTempFolderPath()}/node_modules/.pnpm`; + const modulesFilePath = `${subspace.getSubspaceTempFolderPath()}/node_modules/.modules.yaml`; // we have an edge case here // if a package.json has no dependencies, pnpm will still generate the pnpm-lock.yaml but not .pnpm folder // so we need to make sure pnpm-lock.yaml and .pnpm exists before calling the pnpmSync APIs - if ((await FileSystem.existsAsync(pnpmLockfilePath)) && (await FileSystem.existsAsync(dotPnpmFolder))) { + if ((await FileSystem.existsAsync(pnpmLockfilePath)) && (await FileSystem.existsAsync(dotPnpmFolder)) && (await FileSystem.existsAsync(modulesFilePath))) { await pnpmSyncPrepareAsync({ lockfilePath: pnpmLockfilePath, dotPnpmFolder, From d6857b50e20fa3ff653f171afe9c0f503334c1ee Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Mon, 23 Jun 2025 16:37:40 +0800 Subject: [PATCH 2/3] docs: add rush change --- .../fix-pnpm-sync-modules-yaml_2025-06-23-08-37.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/rush/fix-pnpm-sync-modules-yaml_2025-06-23-08-37.json diff --git a/common/changes/@microsoft/rush/fix-pnpm-sync-modules-yaml_2025-06-23-08-37.json b/common/changes/@microsoft/rush/fix-pnpm-sync-modules-yaml_2025-06-23-08-37.json new file mode 100644 index 00000000000..9bf79c201b2 --- /dev/null +++ b/common/changes/@microsoft/rush/fix-pnpm-sync-modules-yaml_2025-06-23-08-37.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix pnpm-sync caused .modules.yaml ENOENT during install", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file From 1b946286a53ad43d91a59f2a6f256a64a793cd67 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Mon, 23 Jun 2025 17:15:59 +0800 Subject: [PATCH 3/3] style: fix type lint --- libraries/rush-lib/src/logic/base/BaseInstallManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/rush-lib/src/logic/base/BaseInstallManager.ts b/libraries/rush-lib/src/logic/base/BaseInstallManager.ts index 02427c1da0f..f6c15e0e3e1 100644 --- a/libraries/rush-lib/src/logic/base/BaseInstallManager.ts +++ b/libraries/rush-lib/src/logic/base/BaseInstallManager.ts @@ -293,7 +293,7 @@ export abstract class BaseInstallManager { if (this.rushConfiguration.isPnpm && experiments?.usePnpmSyncForInjectedDependencies) { const pnpmLockfilePath: string = subspace.getTempShrinkwrapFilename(); const dotPnpmFolder: string = `${subspace.getSubspaceTempFolderPath()}/node_modules/.pnpm`; - const modulesFilePath = `${subspace.getSubspaceTempFolderPath()}/node_modules/.modules.yaml`; + const modulesFilePath: string = `${subspace.getSubspaceTempFolderPath()}/node_modules/.modules.yaml`; // we have an edge case here // if a package.json has no dependencies, pnpm will still generate the pnpm-lock.yaml but not .pnpm folder