diff --git a/common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json b/common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json new file mode 100644 index 00000000000..48f48622e0b --- /dev/null +++ b/common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Don't interrupt the installation process if the user hasn't enabled the inject dependencies feature.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/RepoStateFile.ts b/libraries/rush-lib/src/logic/RepoStateFile.ts index 6e694dbdc83..41c68e02af0 100644 --- a/libraries/rush-lib/src/logic/RepoStateFile.ts +++ b/libraries/rush-lib/src/logic/RepoStateFile.ts @@ -208,6 +208,12 @@ export class RepoStateFile { ) { this._packageJsonInjectedDependenciesHash = packageJsonInjectedDependenciesHash; this._modified = true; + } else if (!packageJsonInjectedDependenciesHash && this._packageJsonInjectedDependenciesHash) { + // if packageJsonInjectedDependenciesHash is undefined, but this._packageJsonInjectedDependenciesHash is not + // means users may turn off the injected installation + // so we will need to remove unused fields in repo-state.json as well + this._packageJsonInjectedDependenciesHash = undefined; + this._modified = true } } diff --git a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts index 34f46f6f126..2c94c5d8b4d 100644 --- a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts +++ b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts @@ -170,8 +170,11 @@ export class WorkspaceInstallManager extends BaseInstallManager { // there is a situation that the subspace previously has injected dependencies but removed // so we can check if the repoState up to date if (repoState.packageJsonInjectedDependenciesHash !== undefined) { - shrinkwrapWarnings.push(`Some injected dependencies' package.json might have been modified.`); - shrinkwrapIsUpToDate = false; + shrinkwrapWarnings.push( + `It was detected that ${repoState.filePath} contains packageJsonInjectedDependenciesHash` + + ' but the injected dependencies feature is not enabled. You can manually remove this field in repo-state.json.' + + ' Or run rush update command to update the repo-state.json file.' + ); } } }