{"record":{"id":"5fa98b2953613b6d","repo":"coleam00/Archon","slug":"could-not-write-pi-model-config-e-message-cod","errorCode":null,"errorMessage":"Could not write Pi model config: ${e.message}${code}","messagePattern":"Could not write Pi model config: (.+?)(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/setup.ts","lineNumber":2320,"sourceCode":"    const err = error as NodeJS.ErrnoException;\n    const code = err.code ? ` (${err.code})` : '';\n    cancel(`Could not write ${targetEnvPath}${code}: ${err.message}`);\n    process.exit(1);\n  }\n\n  s.stop('Configuration written');\n\n  // Pi model ref lives in ~/.archon/config.yaml, not the .env file, because\n  // it's a structured user preference rather than a secret.\n  if (config.ai.pi && config.ai.piModel) {\n    try {\n      writeHomePiModelConfig(config.ai.piModel);\n    } catch (err) {\n      // Non-fatal: env write already succeeded, so the user can hand-edit\n      // ~/.archon/config.yaml later. Surface the error so it's not silent.\n      const e = err as NodeJS.ErrnoException;\n      const code = e.code ? ` (${e.code})` : '';\n      log.warning(`Could not write Pi model config: ${e.message}${code}`);\n      getLog().warn({ err: e }, 'setup.pi_model_config_write_failed');\n    }\n  }\n\n  // Default assistant (+ optional chat model) → ~/.archon/config.yaml through\n  // the SAME install-scope write path as `archon ai default <provider>\n  // [<model>]` (#1998/#1999). Must run AFTER the Pi block above:\n  // writeHomePiModelConfig refuses to append once an `assistants:` block\n  // exists, and updateGlobalConfig can materialize one — the merge-write here\n  // preserves whatever the Pi writer produced.\n  await writeInstallDefaults(config.ai);\n\n  // Model tiers: confirm built-in defaults (claude/codex) or point providers\n  // without built-ins at the owning config surfaces before anything runs.\n  await confirmModelTiers(config.ai.defaultAssistant);\n\n  // Tell the operator exactly what happened — especially that <repo>/.env was\n  // NOT touched, because prior versions wrote there and this is the biggest","sourceCodeStart":2302,"sourceCodeEnd":2338,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/setup.ts#L2302-L2338","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Fix the filesystem issue indicated by the errno code (permissions, disk space) and re-run `archon setup`.","Hand-edit ~/.archon/config.yaml to set the ai.piModel value, since the env write already succeeded.","Verify the written value later with `archon ai` commands to confirm the Pi model config is in place."],"exampleFix":"// before\n# ~/.archon/config.yaml missing ai.piModel\n// after\nai:\n  piModel: claude-sonnet-4","handlingStrategy":"validation","validationCode":"const dir = path.join(os.homedir(), '.archon');\nfs.mkdirSync(dir, { recursive: true });\nfs.accessSync(dir, fs.constants.W_OK);\nconst cfgPath = path.join(dir, 'config.yaml');\nif (fs.existsSync(cfgPath)) YAML.parse(fs.readFileSync(cfgPath, 'utf8'));","typeGuard":null,"tryCatchPattern":"try {\n  writeHomePiModelConfig(model);\n} catch (e) {\n  const err = e as NodeJS.ErrnoException;\n  log.warn(`Pi model config not written (${err.code ?? 'unknown'}): ${err.message}. Edit ~/.archon/config.yaml manually.`);\n}","preventionTips":["Ensure ~/.archon is owned by the invoking user before running setup.","Close editors/sync tools holding config.yaml open during setup.","After setup, read back the config to confirm ai.piModel is set.","Fall back to `archon ai default <provider> <model>` when automated writes fail."],"tags":["setup","pi-config","filesystem"],"backgroundTag":"config-file-write-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}