Skip to content

Commit

Permalink
Merge pull request microsoft#4039 from iclanton/fix-rush-sdk-loading-…
Browse files Browse the repository at this point in the history
…issue

[rush] Fix an issue where rush-sdk sometimes fails to load if the globally installed Rush package is too old
  • Loading branch information
iclanton authored Mar 30, 2023
2 parents 6ac6247 + aa88666 commit 19ce65c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an issue where rush-sdk sometimes failed to load if the globally installed Rush version was older than rushVersion in rush.json (GitHub #4039)",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
12 changes: 5 additions & 7 deletions libraries/rush-lib/src/utilities/SetRushLibPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { PackageJsonLookup } from '@rushstack/node-core-library';

import { EnvironmentVariableNames } from '../api/EnvironmentConfiguration';

if (!process.env[EnvironmentVariableNames.RUSH_LIB_PATH]) {
const rootDir: string | undefined = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
if (rootDir) {
// Route to the 'main' field of package.json
const rushLibIndex: string = require.resolve(rootDir, { paths: [] });
process.env[EnvironmentVariableNames.RUSH_LIB_PATH] = rushLibIndex;
}
const rootDir: string | undefined = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
if (rootDir) {
// Route to the 'main' field of package.json
const rushLibIndex: string = require.resolve(rootDir, { paths: [] });
process.env[EnvironmentVariableNames.RUSH_LIB_PATH] = rushLibIndex;
}

0 comments on commit 19ce65c

Please sign in to comment.