diff --git a/common/changes/@microsoft/rush/fix-a-missing-variant-case_2024-12-02-22-05.json b/common/changes/@microsoft/rush/fix-a-missing-variant-case_2024-12-02-22-05.json new file mode 100644 index 00000000000..5f7911b0705 --- /dev/null +++ b/common/changes/@microsoft/rush/fix-a-missing-variant-case_2024-12-02-22-05.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix an issue where the ability to skip `rush install` may be incorrectly calculated when using the variants feature.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 454ac3daa07..2ca78be7635 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -1499,7 +1499,7 @@ export class Subspace { // @beta getPackageJsonInjectedDependenciesHash(variant?: string): string | undefined; // @beta - getPnpmConfigFilePath(variant?: string): string; + getPnpmConfigFilePath(): string; // @beta getPnpmfilePath(variant?: string): string; // @beta diff --git a/libraries/rush-lib/src/api/Subspace.ts b/libraries/rush-lib/src/api/Subspace.ts index 0d08f19489f..4a6d4d06ca2 100644 --- a/libraries/rush-lib/src/api/Subspace.ts +++ b/libraries/rush-lib/src/api/Subspace.ts @@ -75,11 +75,10 @@ export class Subspace { public getPnpmOptions(): PnpmOptionsConfiguration | undefined { if (!this._cachedPnpmOptionsInitialized) { // Calculate these outside the try/catch block since their error messages shouldn't be annotated: - const subspaceConfigFolder: string = this.getSubspaceConfigFolderPath(); const subspaceTempFolder: string = this.getSubspaceTempFolderPath(); try { this._cachedPnpmOptions = PnpmOptionsConfiguration.loadFromJsonFileOrThrow( - `${subspaceConfigFolder}/${RushConstants.pnpmConfigFilename}`, + this.getPnpmConfigFilePath(), subspaceTempFolder ); this._cachedPnpmOptionsInitialized = true; @@ -207,7 +206,6 @@ export class Subspace { * - Lockfiles: (i.e. - `pnpm-lock.yaml`, `npm-shrinkwrap.json`, `yarn.lock`, etc) * - 'common-versions.json' * - 'pnpmfile.js'/'.pnpmfile.cjs' - * - 'pnpm-config.js' */ public getVariantDependentSubspaceConfigFolderPath(variant: string | undefined): string { const subspaceConfigFolderPath: string = this.getSubspaceConfigFolderPath(); @@ -303,8 +301,8 @@ export class Subspace { * Example: `C:\MyRepo\common\subspaces\my-subspace\pnpm-config.json` * @beta */ - public getPnpmConfigFilePath(variant?: string): string { - return this.getVariantDependentSubspaceConfigFolderPath(variant) + '/' + RushConstants.pnpmConfigFilename; + public getPnpmConfigFilePath(): string { + return this.getSubspaceConfigFolderPath() + '/' + RushConstants.pnpmConfigFilename; } /** diff --git a/libraries/rush-lib/src/logic/base/BaseInstallManager.ts b/libraries/rush-lib/src/logic/base/BaseInstallManager.ts index a32b444a0a2..c0d081cc23b 100644 --- a/libraries/rush-lib/src/logic/base/BaseInstallManager.ts +++ b/libraries/rush-lib/src/logic/base/BaseInstallManager.ts @@ -399,7 +399,7 @@ export abstract class BaseInstallManager { potentiallyChangedFiles.push(subspace.getCommonVersionsFilePath(variant)); // Add pnpm-config.json file to the potentially changed files list. - potentiallyChangedFiles.push(subspace.getPnpmConfigFilePath(variant)); + potentiallyChangedFiles.push(subspace.getPnpmConfigFilePath()); if (this.rushConfiguration.packageManager === 'pnpm') { // If the repo is using pnpmfile.js, consider that also