-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rush] Add support for RUSH_OVERRIDE_PATH environment variable #5003
base: main
Are you sure you want to change the base?
Conversation
…h through RUSH_OVERRIDE_PATH
} | ||
} | ||
|
||
if (semver.lt(version, '3.0.20')) { | ||
// In old versions, requiring the entry point invoked the command-line parser immediately, | ||
// so fail if "rushx" or "rush-pnpm" was used | ||
RushCommandSelector.failIfNotInvokedAsRush(version); | ||
require(path.join(expectedRushPath, 'node_modules', '@microsoft', 'rush', 'lib', 'rush')); | ||
require(path.join(rushPath, 'lib', 'rush')); | ||
} else if (semver.lt(version, '4.0.0')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is checked twice now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually looks like it's checked in a few places.
"changes": [ | ||
{ | ||
"packageName": "@microsoft/rush", | ||
"comment": "Add support for overriding rush with custom installation path through RUSH_OVERRIDE_PATH environment variable", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"comment": "Add support for overriding rush with custom installation path through RUSH_OVERRIDE_PATH environment variable", | |
"comment": "Add support for overriding Rush with a custom installation path through a new `RUSH_OVERRIDE_PATH` environment variable. This environment variable is intended to be used for development of Rush itself.", |
installIsValid = await installMarker.isValidAsync(); | ||
if (installIsValid) { | ||
console.log('Another process performed the installation.'); | ||
if (semver.lt(version, '4.0.0')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (semver.lt(version, '4.0.0')) { | |
if (isLegacyRushVersion) { |
|
||
const overrideVersion: string = overridePackageJson.version; | ||
|
||
// If we are overriding with an older Rush that doesn't understand the RUSH_OVERRIDE_PATH variable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If we are overriding with an older Rush that doesn't understand the RUSH_OVERRIDE_PATH variable, | |
// If we are overriding with an older version of Rush that doesn't understand the RUSH_OVERRIDE_PATH variable, |
const overridePackageJson: IPackageJson | undefined = PackageJsonLookup.instance.tryLoadPackageJsonFor(overridePath); | ||
|
||
if (overridePackageJson === undefined) { | ||
terminal.writeErrorLine(`Cannot use version specified with "RUSH_OVERRIDE_PATH" environment variable as it doesn't point to valid Rush package: ${overridePath}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terminal.writeErrorLine(`Cannot use version specified with "RUSH_OVERRIDE_PATH" environment variable as it doesn't point to valid Rush package: ${overridePath}`); | |
terminal.writeErrorLine(`Unable to load the a copy of `rush-lib` specified with ` + | |
`the "${EnvironmentVariableNames.RUSH_OVERRIDE_PATH}" environment ` + | |
`variable: ${overridePath}`); |
// If we are overriding with an older Rush that doesn't understand the RUSH_OVERRIDE_PATH variable, | ||
// then unset it. | ||
if (semver.lt(overrideVersion, '5.141.0')) { | ||
delete process.env[EnvironmentVariableNames.RUSH_OVERRIDE_PATH]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just always delete the env var here?
|
||
PrintUtilities.printMessageInBox( | ||
[ | ||
`WARNING! THE "RUSH_OVERRIDE_PATH" ENVIRONMENT VARIABLE IS SET.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`WARNING! THE "RUSH_OVERRIDE_PATH" ENVIRONMENT VARIABLE IS SET.`, | |
`WARNING! THE "${EnvironmentVariableNames.RUSH_OVERRIDE_PATH}" ENVIRONMENT VARIABLE IS SET.`, |
...( | ||
configuration | ||
? [ | ||
`The rush.json configuration asks for: @${configuration.rushVersion}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`The rush.json configuration asks for: @${configuration.rushVersion}`, | |
`The ${RushConstants.rushJsonFilename} configuration asks for v${configuration.rushVersion}`, |
Summary
While contributing to Rush, I've discovered that there's no easy way to test it with my company's repo as we heavily use VSCode tasks.json that hardcode "rush" command for many operations (so using method described in https://rushjs.io/pages/contributing/#testing-rush-builds is not possible as it would involve replacing all "rush" occurrences with "testrush").
Details
This PR introduces support for the
RUSH_OVERRIDE_PATH
environment variable, which can specify the path to the custom Rush installation. This way, contributors can override the Rush installation used by the repository and test any changes that are being made to Rush, even if therush
command is hardcoded somewhere.If
RUSH_OVERRIDE_PATH
is present, the user is presented with a warning similar to the one displayed when using theRUSH_PREVIEW_VERSION
environment variable.How it was tested
I've set
RUSH_OVERRIDE_PATH
that points to custom Rush installation and executednode apps\rush\bin\rush build --help
- seems to be working.Impacted documentation
https://rushjs.io/pages/contributing