hcengineering/platform · error

Unable to find ${RUSH_JSON_FILENAME}.

Error message

Unable to find ${RUSH_JSON_FILENAME}.

What it means

findRushJsonFolder walks up from the current directory (via __dirname of the script and successive path.dirname calls) looking for rush.json. If it reaches the disk root without finding one and _rushJsonFolder was never set, it throws 'Unable to find rush.json.' The script requires being run inside (or below) a Rush repository.

Source

Thrown at foundations/net/common/scripts/install-run.js:548

/**
 * Find the absolute path to the folder containing rush.json
 */
function findRushJsonFolder() {
    if (!_rushJsonFolder) {
        let basePath = __dirname;
        let tempPath = __dirname;
        do {
            const testRushJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(basePath, RUSH_JSON_FILENAME);
            if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(testRushJsonPath)) {
                _rushJsonFolder = basePath;
                break;
            }
            else {
                basePath = tempPath;
            }
        } while (basePath !== (tempPath = path__WEBPACK_IMPORTED_MODULE_3__.dirname(basePath))); // Exit the loop when we hit the disk root
        if (!_rushJsonFolder) {
            throw new Error(`Unable to find ${RUSH_JSON_FILENAME}.`);
        }
    }
    return _rushJsonFolder;
}
/**
 * Detects if the package in the specified directory is installed
 */
function _isPackageAlreadyInstalled(packageInstallFolder) {
    try {
        const flagFilePath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
        if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(flagFilePath)) {
            return false;
        }
        const fileContents = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(flagFilePath).toString();
        return fileContents.trim() === process.version;
    }
    catch (e) {
        return false;

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Run the script from inside a Rush repository (any folder that has rush.json in it or an ancestor).
  2. Verify rush.json exists at the repo root and is named exactly 'rush.json' (not rushx.json, rush.json5, etc.).
  3. Fix CI cwd so the job starts in the cloned repository directory.
  4. If invoking from elsewhere, cd into the repo first: the upward search starts near the script location/working directory.
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
const path = require('path');
function assertInsideRushRepo(startDir) {
  let dir = path.resolve(startDir);
  for (;;) {
    if (fs.existsSync(path.join(dir, 'rush.json'))) return dir;
    const parent = path.dirname(dir);
    if (parent === dir) throw new Error(`No rush.json found above ${startDir}; run from inside a Rush repo.`);
    dir = parent;
  }
}
assertInsideRushRepo(process.cwd());

Try / catch

try {
  runInstallRun();
} catch (e) {
  if (/Unable to find rush\.json/.test(e.message)) {
    console.error('Run this script from inside a Rush monorepo (rush.json not found in any parent directory).');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running install-run-rush.js (or the install-run scripts that call findRushJsonFolder via rushJsonFolder) from a directory outside any Rush monorepo — no rush.json exists in the current folder or any ancestor up to the filesystem root.

Common situations: Cloning only a subfolder of a monorepo without the root; running the script in a temp/CI working directory that never had rush.json; renaming or deleting rush.json; running the script outside the repo entirely (e.g. from $HOME on a CI runner).

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/f830e4b25a171f21. Report an issue: GitHub.