affaan-m/ECC · error · Error

Refusing to ${action} '${target}': no trusted install root r

Error message

Refusing to ${action} '${target}': no trusted install root resolved.

What it means

Thrown by assertWithinTrustedRoot when `target` is a valid string but `root` (the trusted install root) is falsy. The guard cannot confine a path without a trusted root to confine against, so it fails closed rather than defaulting to cwd or any implicit base.

Source

Thrown at scripts/lib/path-safety.js:90

  }

  try {
    return resolveContainment(target, root).contained;
  } catch {
    return false;
  }
}

/**
 * Fail-closed guard: throw unless `target` is contained within `root`.
 * Returns the canonicalized target path on success.
 */
function assertWithinTrustedRoot(target, root, action = 'write') {
  if (!target || typeof target !== 'string') {
    throw new Error(`Refusing to ${action}: missing destination path.`);
  }
  if (!root) {
    throw new Error(`Refusing to ${action} '${target}': no trusted install root resolved.`);
  }

  let containment;
  try {
    containment = resolveContainment(target, root);
  } catch {
    containment = null;
  }
  if (!containment || !containment.contained) {
    throw new Error(`Refusing to ${action} outside the install root: '${target}' is not within '${root}'.`);
  }
  return containment.realTarget;
}

module.exports = {
  realpathNearestExisting,
  isWithinRoot,
  assertWithinTrustedRoot

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Resolve and verify a trusted root before invoking any install/repair/uninstall operation.
  2. Fail early with a clear error if no adapter root is available, instead of passing undefined downstream.
  3. Check isWithinRoot(target, root) returns false rather than calling assert when root may be absent.
  4. Ensure the harness/adapter is configured (e.g. CLAUDE_CONFIG_DIR) so the root resolves.

Example fix

// before
const trustedRoot = adapter.resolveRoot(); // returns undefined
assertWithinTrustedRoot(dest, trustedRoot, 'write');

// after
const trustedRoot = adapter.resolveRoot();
if (!trustedRoot) throw new Error('No trusted install root for harness ' + adapter.id);
assertWithinTrustedRoot(dest, trustedRoot, 'write');
Defensive patterns

Strategy: validation

Validate before calling

if (!root) throw new Error('No trusted install root resolved; configure the adapter.');
assertWithinTrustedRoot(target, root, action);

Prevention

When it happens

Trigger: Calling assertWithinTrustedRoot(dest, undefined, 'write'), assertWithinTrustedRoot(dest, '', 'write'), or passing a root derived from an adapter that returned null because no trusted root could be resolved for the current harness.

Common situations: An adapter (claude/cursor/codex) failing to resolve its target directory; a multi-harness setup where the harness type is unset so no root maps; running an install-lifecycle operation outside a project; a config migration that left the root resolution returning empty.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/564cbb47627aa446. Report an issue: GitHub.