{"record":{"id":"09cf94b5ee5f2906","repo":"hcengineering/platform","slug":"unable-to-find-rush-json-filename-09cf94","errorCode":null,"errorMessage":"Unable to find ${RUSH_JSON_FILENAME}.","messagePattern":"Unable to find (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/common/scripts/install-run.js","lineNumber":548,"sourceCode":"/**\n * Find the absolute path to the folder containing rush.json\n */\nfunction findRushJsonFolder() {\n    if (!_rushJsonFolder) {\n        let basePath = __dirname;\n        let tempPath = __dirname;\n        do {\n            const testRushJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(basePath, RUSH_JSON_FILENAME);\n            if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(testRushJsonPath)) {\n                _rushJsonFolder = basePath;\n                break;\n            }\n            else {\n                basePath = tempPath;\n            }\n        } while (basePath !== (tempPath = path__WEBPACK_IMPORTED_MODULE_3__.dirname(basePath))); // Exit the loop when we hit the disk root\n        if (!_rushJsonFolder) {\n            throw new Error(`Unable to find ${RUSH_JSON_FILENAME}.`);\n        }\n    }\n    return _rushJsonFolder;\n}\n/**\n * Detects if the package in the specified directory is installed\n */\nfunction _isPackageAlreadyInstalled(packageInstallFolder) {\n    try {\n        const flagFilePath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);\n        if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(flagFilePath)) {\n            return false;\n        }\n        const fileContents = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(flagFilePath).toString();\n        return fileContents.trim() === process.version;\n    }\n    catch (e) {\n        return false;","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/common/scripts/install-run.js#L530-L566","documentation":"findRushJsonFolder walks up from the current directory toward the filesystem root looking for rush.json, caching the result. If it reaches the disk root without finding rush.json, it throws 'Unable to find rush.json'. The library throws this because install-run must know the repo root to locate common/temp and the package install folder.","triggerScenarios":"Running (or importing) install-run.js from a directory that is not inside a Rush monorepo, or from a subfolder whose ancestor chain contains no rush.json; the script was copied out of the repo and executed elsewhere.","commonSituations":"CI job checking out only a subdirectory of the repo; running the script from $HOME or a temp dir; rush.json renamed/moved or repo root misconfigured; invoking the script outside the monorepo during local debugging.","solutions":["Run the script from within the Rush repository (a directory containing rush.json in itself or an ancestor).","Verify rush.json exists at the repo root and was checked out (full clone, not a sparse/partial checkout).","cd to a folder inside the repo before invoking install-run-rush.js / install-run.js.","If the folder is genuinely a Rush root, confirm rush.json is committed and not gitignored."],"exampleFix":"// before (run from outside repo)\ncd ~ && node repo/common/scripts/install-run-rush.js\n// after\ncd /path/to/rush-repo && node common/scripts/install-run-rush.js","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction assertInsideRushRepo(startDir) {\n  let dir = path.resolve(startDir);\n  while (true) {\n    if (fs.existsSync(path.join(dir, 'rush.json'))) return dir;\n    const parent = path.dirname(dir);\n    if (parent === dir) throw new Error('rush.json not found; run from inside a Rush repo');\n    dir = parent;\n  }\n}\nassertInsideRushRepo(process.cwd());","typeGuard":"function isRushJsonFolder(dir) {\n  const fs = require('fs'); const path = require('path');\n  return typeof dir === 'string' && fs.existsSync(path.join(dir, 'rush.json'));\n}","tryCatchPattern":"try {\n  installAndRun(logger, name, version, bin, args);\n} catch (e) {\n  if (/Unable to find rush\\.json/.test(e.message)) {\n    console.error('Run this script from within a Rush monorepo (rush.json must exist in an ancestor folder).');\n  }\n  throw e;\n}","preventionTips":["Always invoke install-run scripts from inside the Rush repo checkout","Ensure full checkouts in CI (avoid sparse checkout dropping rush.json)","Keep rush.json committed at the repo root","Add a pre-flight check that rush.json exists before bootstrap scripts run"],"tags":["rush","monorepo","config","script"],"backgroundTag":"rush-json-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}