coleam00/Archon · warning

Could not write Pi model config: ${e.message}${code}

Error message

Could not write Pi model config: ${e.message}${code}

What it means

A non-fatal warning raised when setup cannot write the Pi model configuration after the environment (.env) write already succeeded. Setup surfaces the error and continues, noting the user can hand-edit ~/.archon/config.yaml instead. The errno code, if any, is appended to the message to identify the filesystem cause.

Source

Thrown at packages/cli/src/commands/setup.ts:2320

    const err = error as NodeJS.ErrnoException;
    const code = err.code ? ` (${err.code})` : '';
    cancel(`Could not write ${targetEnvPath}${code}: ${err.message}`);
    process.exit(1);
  }

  s.stop('Configuration written');

  // Pi model ref lives in ~/.archon/config.yaml, not the .env file, because
  // it's a structured user preference rather than a secret.
  if (config.ai.pi && config.ai.piModel) {
    try {
      writeHomePiModelConfig(config.ai.piModel);
    } catch (err) {
      // Non-fatal: env write already succeeded, so the user can hand-edit
      // ~/.archon/config.yaml later. Surface the error so it's not silent.
      const e = err as NodeJS.ErrnoException;
      const code = e.code ? ` (${e.code})` : '';
      log.warning(`Could not write Pi model config: ${e.message}${code}`);
      getLog().warn({ err: e }, 'setup.pi_model_config_write_failed');
    }
  }

  // Default assistant (+ optional chat model) → ~/.archon/config.yaml through
  // the SAME install-scope write path as `archon ai default <provider>
  // [<model>]` (#1998/#1999). Must run AFTER the Pi block above:
  // writeHomePiModelConfig refuses to append once an `assistants:` block
  // exists, and updateGlobalConfig can materialize one — the merge-write here
  // preserves whatever the Pi writer produced.
  await writeInstallDefaults(config.ai);

  // Model tiers: confirm built-in defaults (claude/codex) or point providers
  // without built-ins at the owning config surfaces before anything runs.
  await confirmModelTiers(config.ai.defaultAssistant);

  // Tell the operator exactly what happened — especially that <repo>/.env was
  // NOT touched, because prior versions wrote there and this is the biggest

View on GitHub (pinned to 0773b97458)

Solutions

  1. Fix the filesystem issue indicated by the errno code (permissions, disk space) and re-run `archon setup`.
  2. Hand-edit ~/.archon/config.yaml to set the ai.piModel value, since the env write already succeeded.
  3. Verify the written value later with `archon ai` commands to confirm the Pi model config is in place.

Example fix

// before
# ~/.archon/config.yaml missing ai.piModel
// after
ai:
  piModel: claude-sonnet-4
Defensive patterns

Strategy: validation

Validate before calling

const dir = path.join(os.homedir(), '.archon');
fs.mkdirSync(dir, { recursive: true });
fs.accessSync(dir, fs.constants.W_OK);
const cfgPath = path.join(dir, 'config.yaml');
if (fs.existsSync(cfgPath)) YAML.parse(fs.readFileSync(cfgPath, 'utf8'));

Try / catch

try {
  writeHomePiModelConfig(model);
} catch (e) {
  const err = e as NodeJS.ErrnoException;
  log.warn(`Pi model config not written (${err.code ?? 'unknown'}): ${err.message}. Edit ~/.archon/config.yaml manually.`);
}

Prevention

When it happens

Trigger: During `archon setup`, after writeHomePiModelConfig is invoked with the chosen ai.piModel, the underlying file write throws (EACCES on ~/.archon, ENOSPC, file locked by editor/sync tool, or a serialization failure building the Pi config structure).

Common situations: Running setup under a different user than the one owning ~/.archon, disk quota exceeded, or editing ~/.archon/config.yaml in an editor that holds a lock while setup runs.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/5fa98b2953613b6d. Report an issue: GitHub.