affaan-m/ECC · error · Error

Cannot locate above

Error message

Cannot locate ${repoRelativePath} above ${__dirname}

What it means

resolveRepoModule walks up from __dirname looking for a repo-relative module (e.g. scripts/lib/hooks-config.js) and throws when no ancestor directory contains it. This happens when the validator is copied out of the repo without the referenced library, or the library file was moved/deleted — the faulting input is repoRelativePath.

Solutions

  1. Run the validator from a full checkout that contains scripts/lib/hooks-config.js.
  2. Restore the missing library file or fix the repoRelativePath constant.
  3. If used in a copied test harness, copy the lib directory alongside the validator.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at scripts/ci/validate-hooks.js:30 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/91829aa74600fdf6. Report an issue: GitHub.

Appendix: source

Thrown at scripts/ci/validate-hooks.js:30

 * Resolve a module by its repo-relative path.
 *
 * Test harnesses copy this validator to the repo root before running it, so a
 * plain relative require would break. Walk up from __dirname until the module
 * is found instead.
 *
 * @param {string} repoRelativePath - e.g. 'scripts/lib/hooks-config.js'
 * @returns {string} absolute path to the module
 */
function resolveRepoModule(repoRelativePath) {
  let dir = __dirname;
  for (;;) {
    const candidate = path.join(dir, repoRelativePath);
    if (fs.existsSync(candidate)) {
      return candidate;
    }
    const parent = path.dirname(dir);
    if (parent === dir) {
      throw new Error(`Cannot locate ${repoRelativePath} above ${__dirname}`);
    }
    dir = parent;
  }
}

const {
  METADATA_FILENAME,
  applyHooksMetadata,
  findMetadataMismatches,
  metadataPathFor,
  withRefreshedFingerprints,
} = require(resolveRepoModule('scripts/lib/hooks-config.js'));

const HOOKS_FILE = path.join(__dirname, '../../hooks/hooks.json');
const HOOKS_SCHEMA_PATH = path.join(__dirname, '../../schemas/hooks.schema.json');
const METADATA_SCHEMA_PATH = path.join(__dirname, '../../schemas/hooks-metadata.schema.json');
// `--update-fingerprints` rewrites the sidecar's fingerprints from the current
// hooks.json instead of validating. Run it after changing a hook command.

View on GitHub (pinned to 8321021c54)