From a964b8be126c1e346ad8512663092ba9964048b1 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Mon, 6 Mar 2023 11:22:54 -0800 Subject: [PATCH] Do not delete the local pnpm store after all install attempts has failed. --- ...ove-pnpm-store-purge_2023-03-06-19-22.json | 10 ++++ .../installManager/RushInstallManager.ts | 57 +++++++------------ 2 files changed, 30 insertions(+), 37 deletions(-) create mode 100644 common/changes/@microsoft/rush/remove-pnpm-store-purge_2023-03-06-19-22.json diff --git a/common/changes/@microsoft/rush/remove-pnpm-store-purge_2023-03-06-19-22.json b/common/changes/@microsoft/rush/remove-pnpm-store-purge_2023-03-06-19-22.json new file mode 100644 index 00000000000..6102e3300fe --- /dev/null +++ b/common/changes/@microsoft/rush/remove-pnpm-store-purge_2023-03-06-19-22.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Do not delete the local pnpm store after all install attempts has failed. `rush purge` will still delete a local store.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/installManager/RushInstallManager.ts b/libraries/rush-lib/src/logic/installManager/RushInstallManager.ts index 9889de84da1..14847602cab 100644 --- a/libraries/rush-lib/src/logic/installManager/RushInstallManager.ts +++ b/libraries/rush-lib/src/logic/installManager/RushInstallManager.ts @@ -575,45 +575,28 @@ export class RushInstallManager extends BaseInstallManager { ); } - try { - Utilities.executeCommandWithRetry( - { - command: packageManagerFilename, - args: installArgs, - workingDirectory: this.rushConfiguration.commonTempFolder, - environment: packageManagerEnv, - suppressOutput: false - }, - this.options.maxInstallAttempts, - () => { - if (this.rushConfiguration.packageManager === 'pnpm') { - console.log(colors.yellow(`Deleting the "node_modules" folder`)); - this.installRecycler.moveFolder(commonNodeModulesFolder); - - // Leave the pnpm-store as is for the retry. This ensures that packages that have already - // been downloaded need not be downloaded again, thereby potentially increasing the chances - // of a subsequent successful install. - - Utilities.createFolderWithRetry(commonNodeModulesFolder); - } + Utilities.executeCommandWithRetry( + { + command: packageManagerFilename, + args: installArgs, + workingDirectory: this.rushConfiguration.commonTempFolder, + environment: packageManagerEnv, + suppressOutput: false + }, + this.options.maxInstallAttempts, + () => { + if (this.rushConfiguration.packageManager === 'pnpm') { + console.log(colors.yellow(`Deleting the "node_modules" folder`)); + this.installRecycler.moveFolder(commonNodeModulesFolder); + + // Leave the pnpm-store as is for the retry. This ensures that packages that have already + // been downloaded need not be downloaded again, thereby potentially increasing the chances + // of a subsequent successful install. + + Utilities.createFolderWithRetry(commonNodeModulesFolder); } - ); - } catch (error) { - // All the install attempts failed. - - if ( - this.rushConfiguration.packageManager === 'pnpm' && - this.rushConfiguration.pnpmOptions.pnpmStore === 'local' - ) { - // If the installation has failed even after the retries, then pnpm store may - // have got into a corrupted, irrecoverable state. Delete the store so that a - // future install can create the store afresh. - console.log(colors.yellow(`Deleting the "pnpm-store" folder`)); - this.installRecycler.moveFolder(this.rushConfiguration.pnpmOptions.pnpmStorePath); } - - throw error; - } + ); if (this.rushConfiguration.packageManager === 'npm') { console.log('\n' + colors.bold('Running "npm shrinkwrap"...'));