affaan-m/ECC · error · Error

No install-state available for repair

Error message

No install-state available for repair

What it means

createRepairPlanFromRecord reads record.state and refuses to plan a repair when it is null/undefined. Without the recorded install-state there is no list of operations to replay, so the repair cannot know what to restore.

Source

Thrown at scripts/lib/install-lifecycle.js:1309

      okCount: 0,
      errorCount: 0,
      warningCount: 0
    }
  );

  return {
    generatedAt: new Date().toISOString(),
    packageVersion: context.packageVersion,
    manifestVersion: context.manifestVersion,
    results,
    summary
  };
}

function createRepairPlanFromRecord(record, context, options = {}) {
  const state = record.state;
  if (!state) {
    throw new Error('No install-state available for repair');
  }

  if (state.request.legacyMode || shouldRepairFromRecordedOperations(state)) {
    const operations = hydrateRecordedOperations(context.repoRoot, getManagedOperations(state));
    const statePreview = buildRecordedStatePreview(state, context, operations);

    return {
      mode: state.request.legacyMode ? 'legacy' : 'recorded',
      target: record.adapter.target,
      adapter: record.adapter,
      targetRoot: state.target.root,
      installRoot: state.target.root,
      installStatePath: state.target.installStatePath,
      warnings: [],
      languages: Array.isArray(state.request.legacyLanguages) ? [...state.request.legacyLanguages] : [],
      operations,
      statePreview
    };

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Inspect the install-state file at record.installStatePath — confirm it contains a top-level `state` object with `request`, `target`, and `operations`.
  2. If the state is missing or empty, perform a fresh install to regenerate it instead of repairing.
  3. Restore the install-state file from backup if one exists.
  4. Check file permissions/ownership so the installer can read the full file.

Example fix

// before: install-state.json = { "adapter": {...} } /* no state */
// after:
rm install-state.json
./install.sh --target claude
./install.sh --target claude --repair
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function loadRepairableRecord(installStatePath) {
  const raw = JSON.parse(fs.readFileSync(installStatePath, 'utf8'));
  if (!raw || typeof raw !== 'object' || !raw.state) {
    throw new Error('install-state has no `state`; reinstall to regenerate');
  }
  return raw;
}
// call before repair planning

Type guard

function recordHasState(record) {
  return Boolean(record && typeof record === 'object' && record.state);
}

Try / catch

try {
  plan = createRepairPlanFromRecord(record, ctx);
} catch (err) {
  if (err.message === 'No install-state available for repair') {
    // re-install to regenerate state, then retry repair
  } else throw err;
}

Prevention

When it happens

Trigger: Invoking repair on a target whose install-state file exists but parsed to a record with no `state` field — e.g. the file is `{}`, truncated, or only contains adapter metadata without the operations payload.

Common situations: Install-state file was manually emptied or truncated; a prior installer bug wrote only the wrapper object; the state was wiped by an uninstall that removed operations but left the file behind; permission error caused a partial read.

Related errors


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