{"record":{"id":"2703647e73a64f8f","repo":"hcengineering/platform","slug":"unable-to-determine-the-required-version-of-rush-f-270364","errorCode":null,"errorMessage":"Unable to determine the required version of Rush from rush.json (${rushJsonFolder}). The 'rushVersion' field is either not assigned in rush.json or was specified using an unexpected syntax.","messagePattern":"Unable to determine the required version of Rush from rush\\.json \\((.+?)\\)\\. The 'rushVersion' field is either not assigned in rush\\.json or was specified using an unexpected syntax\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/utils/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/utils/common/scripts/install-run-rush.js#L125-L161","documentation":"install-run-rush.js reads rush.json and extracts the rushVersion field with a regex (because rush.json allows comments). If reading/parsing fails or the regex doesn't match — rushVersion missing, empty, or in an unexpected syntax — _getRushVersion throws this descriptive error.","triggerScenarios":"Running install-run-rush.js (e.g. via a rush bootstrap script) in a repo whose rush.json lacks a valid \"rushVersion\": \"x.y.z\" string, or where the file cannot be read.","commonSituations":"Freshly scaffolded repo where rush.json was hand-edited and rushVersion removed; malformed JSON; rushVersion written with a syntax the regex doesn't accept (e.g. non-sem chars).","solutions":["Open rush.json and set \"rushVersion\" to a valid version string, e.g. \"rushVersion\": \"5.100.0\"","Validate rush.json is readable, valid JSON-with-comments, and the version matches [0-9a-zA-Z.+-]+","Restore rush.json from the repo template if it was corrupted"],"exampleFix":"// before (rush.json)\n{\n  // no rushVersion\n  \"repository\": {...}\n}\n// after (rush.json)\n{\n  \"rushVersion\": \"5.100.0\",\n  \"repository\": {...}\n}","handlingStrategy":"try-catch","validationCode":"const fs = require('fs')\nfunction assertRushVersion(rushJsonFolder) {\n  const contents = fs.readFileSync(`${rushJsonFolder}/rush.json`, 'utf8')\n  const m = contents.match(/\\\"rushVersion\\\"\\s*:\\s*\\\"([0-9a-zA-Z.+\\-]+)\\\"/)\n  if (!m) throw new Error('rush.json is missing a valid rushVersion string')\n}","typeGuard":"function hasRushVersion(rushJsonContents) {\n  return /\\\"rushVersion\\\"\\s*:\\s*\\\"[0-9a-zA-Z.+\\-]+\\\"/.test(rushJsonContents)\n}","tryCatchPattern":"try {\n  require('./common/scripts/install-run-rush.js')\n} catch (e) {\n  if (String(e.message).includes(\"Unable to determine the required version of Rush\")) {\n    console.error('Fix rush.json: add \"rushVersion\": \"x.y.z\" (valid chars: [0-9a-zA-Z.+-])')\n    process.exit(1)\n  }\n  throw e\n}","preventionTips":["Never remove rushVersion when hand-editing rush.json; keep it at the top with a comment","Add a repo lint/CI check asserting rushVersion matches the expected regex","Regenerate rush.json from the rush template rather than editing from scratch"],"tags":["rush","build-tooling","configuration"],"backgroundTag":"missing-config-field","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}