{"record":{"id":"b88fd87dcbf7fd97","repo":"coleam00/Archon","slug":"could-not-write-default-assistant-config-e-mess","errorCode":null,"errorMessage":"Could not write default assistant config: ${e.message}${code}","messagePattern":"Could not write default assistant config: (.+?)(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/setup.ts","lineNumber":760,"sourceCode":" * aborting setup. Returns true when the config was written.\n *\n * The `write` parameter is injected in tests (same convention as\n * checkPiModule's loader) so this path is testable without `mock.module()`.\n */\nexport async function writeInstallDefaults(\n  ai: SetupConfig['ai'],\n  write: (provider: string, model?: string) => Promise<void> = setInstallDefault\n): Promise<boolean> {\n  if (!ai.defaultAssistantSelected) return false;\n  try {\n    await write(ai.defaultAssistant, ai.defaultModel);\n    return true;\n  } catch (err) {\n    // Non-fatal: the user can run `archon ai default <provider> [<model>]`\n    // later. Surface, don't swallow.\n    const e = err as NodeJS.ErrnoException;\n    const code = e.code ? ` (${e.code})` : '';\n    log.warning(`Could not write default assistant config: ${e.message}${code}`);\n    getLog().warn({ err: e }, 'setup.default_assistant_config_write_failed');\n    return false;\n  }\n}\n\n/**\n * Verify the Pi npm module is loadable. Pi is bundled as a transitive dep of\n * `@archon/providers` so this should always pass, but catching broken compiled\n * builds at setup time is preferable to a silent runtime failure.\n *\n * The `loader` parameter is injected in tests so we don't need\n * `mock.module()` on `@archon/providers` (which would pollute other tests).\n */\nexport async function checkPiModule(\n  loader: () => Promise<unknown> = () => import('@archon/providers')\n): Promise<{ ok: boolean; error?: string }> {\n  try {\n    await loader();","sourceCodeStart":742,"sourceCodeEnd":778,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/setup.ts#L742-L778","documentation":"A non-fatal warning emitted during `archon setup` when writing the default assistant configuration (to ~/.archon/config.yaml via writeInstallDefaults) fails. Setup catches the error, logs it, and returns false so the user can later run `archon ai default <provider> [<model>]`. The message embeds the underlying error text and, when present, the Node.js errno code (e.g. EACCES, ENOSPC) to pinpoint the cause.","triggerScenarios":"Running `archon setup` and choosing to configure a default assistant when the write to the config file fails: unwritable ~/.archon directory, disk full, config.yaml corrupted/unparseable by the YAML writer, or a race with another writer holding the file.","commonSituations":"Home directory permissions changed after running as another user (root-created ~/.archon), read-only or full disk, antivirus/file-sync locking the config file, or a partially-written config.yaml left by a crashed setup.","solutions":["Check the errno code in the warning: fix permissions with `sudo chown -R $(whoami) ~/.archon` for EACCES/EPERM, or free disk space for ENOSPC.","Run `archon ai default <provider> [<model>]` after fixing the environment to write the default assistant config directly.","Hand-edit ~/.archon/config.yaml to set the default assistant/model if automated writes keep failing.","Re-run `archon setup` once the underlying filesystem problem is resolved."],"exampleFix":"// before (root-owned config blocks write)\n-rw------- root root ~/.archon/config.yaml\n// after\nsudo chown -R $(whoami):$(id -gn) ~/.archon\narchon ai default anthropic claude-sonnet-4","handlingStrategy":"validation","validationCode":"const cfg = path.join(os.homedir(), '.archon', 'config.yaml');\nfs.mkdirSync(path.dirname(cfg), { recursive: true });\nfs.accessSync(path.dirname(cfg), fs.constants.W_OK);\nif (fs.existsSync(cfg)) YAML.parse(fs.readFileSync(cfg, 'utf8')); // throws early if corrupt","typeGuard":null,"tryCatchPattern":"try {\n  writeInstallDefaults(prefs);\n} catch (e) {\n  const err = e as NodeJS.ErrnoException;\n  log.warn(`default assistant config not written (${err.code ?? 'unknown'}): ${err.message}. Run: archon ai default <provider> [<model>]`);\n}","preventionTips":["Check writability of ~/.archon before setup (touch a file).","Never run setup with sudo; fix ownership with chown instead.","Keep free disk headroom on the home filesystem.","Validate ~/.archon/config.yaml parses as YAML before programmatic writes."],"tags":["setup","config-write","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"}