{"record":{"id":"7f40a29f056095da","repo":"hcengineering/platform","slug":"unable-to-determine-the-required-version-of-rush-f-7f40a2","errorCode":null,"errorMessage":"Unable to determine the required version of Rush from ${RUSH_JSON_FILENAME} (${rushJsonFolder}). The 'rushVersion' field is either not assigned in ${RUSH_JSON_FILENAME} or was specified using an unexpected syntax.","messagePattern":"Unable to determine the required version of Rush from (.+?) \\((.+?)\\)\\. The 'rushVersion' field is either not assigned in (.+?) or was specified using an unexpected syntax\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/common/scripts/install-run-rush.js","lineNumber":143,"sourceCode":"const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION';\nconst INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_RUSH_LOCKFILE_PATH';\nfunction _getRushVersion(logger) {\n    const rushPreviewVersion = process.env[RUSH_PREVIEW_VERSION];\n    if (rushPreviewVersion !== undefined) {\n        logger.info(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`);\n        return rushPreviewVersion;\n    }\n    const rushJsonFolder = findRushJsonFolder();\n    const rushJsonPath = path__WEBPACK_IMPORTED_MODULE_0__.join(rushJsonFolder, RUSH_JSON_FILENAME);\n    try {\n        const rushJsonContents = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(rushJsonPath, 'utf-8');\n        // Use a regular expression to parse out the rushVersion value because rush.json supports comments,\n        // but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script.\n        const rushJsonMatches = rushJsonContents.match(/\\\"rushVersion\\\"\\s*\\:\\s*\\\"([0-9a-zA-Z.+\\-]+)\\\"/);\n        return rushJsonMatches[1];\n    }\n    catch (e) {\n        throw new Error(`Unable to determine the required version of Rush from ${RUSH_JSON_FILENAME} (${rushJsonFolder}). ` +\n            `The 'rushVersion' field is either not assigned in ${RUSH_JSON_FILENAME} or was specified ` +\n            'using an unexpected syntax.');\n    }\n}\nfunction _getBin(scriptName) {\n    switch (scriptName.toLowerCase()) {\n        case 'install-run-rush-pnpm.js':\n            return 'rush-pnpm';\n        case 'install-run-rushx.js':\n            return 'rushx';\n        default:\n            return 'rush';\n    }\n}\nfunction _run() {\n    const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;\n    // Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the\n    // appropriate binary inside the rush package to run","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/common/scripts/install-run-rush.js#L125-L161","documentation":"This bootstrap script reads rush.json to find the required rushVersion via a regex, because rush.json supports comments that JSON.parse cannot handle. If the regex fails to match (no rushVersion field, or malformed/unexpected syntax), the catch block wraps any failure in this error so the launcher knows which Rush version to install.","triggerScenarios":"Running install-run-rush.js when rush.json has no \"rushVersion\" field, the field is not a quoted string (e.g. a number or missing quotes), or the file cannot be read/parsed in the catch-guarded block.","commonSituations":"Upgraded repos where rush.json schema changed; hand-edited rush.json that dropped rushVersion; running the script from a folder where the wrong/placeholder rush.json was found (e.g. no rush.json in repo root).","solutions":["Open rush.json in the repo root and ensure a valid quoted field exists, e.g. \"rushVersion\": \"5.x.x\"","Match the version syntax expected by the regex (letters, digits, dots, +, -) and keep it double-quoted with standard JSON spacing","Run `rush update` or restore rush.json from version control if it was hand-edited"],"exampleFix":"// before (rush.json)\n{ \"folderPermanentName\": \"...\" }\n// after (rush.json)\n{ \"rushVersion\": \"5.100.1\", ... }","handlingStrategy":"validation","validationCode":"const contents = fs.readFileSync('rush.json', 'utf8');\nif (!/\\\"rushVersion\\\"\\s*:\\s*\\\"[0-9a-zA-Z.+\\-]+\\\"/.test(contents)) throw new Error('rush.json is missing a valid quoted rushVersion field');","typeGuard":null,"tryCatchPattern":"try { require('./common/scripts/install-run-rush.js'); }\ncatch (e) { if (/Unable to determine the required version of Rush/.test(e.message)) { console.error('Fix rush.json rushVersion field'); process.exit(1); } throw e; }","preventionTips":["Never hand-edit rush.json; let `rush update` manage it","Keep rush.json in version control so it can be restored","Validate rush.json after merges/upgrades that touch repo tooling"],"tags":["config","rush","monorepo","parsing"],"backgroundTag":"missing-config-field","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}