{"record":{"id":"5ed2637c484733b0","repo":"Hmbown/CodeWhale","slug":"failed-to-create-first-run-config-file-err","errorCode":null,"errorMessage":"Failed to create first-run config file: {err}","messagePattern":"Failed to create first-run config file: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/lib.rs","lineNumber":11199,"sourceCode":"            || crate::config::explicit_launch_model_override().is_some();\n        apply_selected_fleet_operator_for_launch(\n            &mut merged_config,\n            &workspace,\n            explicit_route_override,\n            false,\n        )?;\n    }\n    let config = &merged_config;\n    initialize_cloud_facts(config);\n\n    if !cli.skip_onboarding {\n        match crate::config::ensure_config_file_exists(cli.config.clone()) {\n            Ok(Some(path)) => logging::info(format!(\n                \"Created first-run config file at {}\",\n                path.display()\n            )),\n            Ok(None) => {}\n            Err(err) => logging::warn(format!(\"Failed to create first-run config file: {err}\")),\n        }\n    }\n\n    // v0.8.44: migrate config from ~/.deepseek/ to ~/.codewhale/ on first\n    // launch. Non-fatal — existing installs keep working either way.\n    match codewhale_config::migrate_config_if_needed() {\n        Ok(Some(migration)) => {\n            eprintln!(\"{}\", migration.user_notice());\n        }\n        Ok(None) => {}\n        Err(err) => logging::warn(format!(\"Config migration skipped: {err}\")),\n    }\n\n    let model = config.default_model();\n    let provider = config.api_provider();\n    let max_subagents = cli.max_subagents.map_or_else(\n        || config.max_subagents_for_provider(provider),\n        |value| value.clamp(1, MAX_SUBAGENTS),","sourceCodeStart":11181,"sourceCodeEnd":11217,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/lib.rs#L11181-L11217","documentation":"On first launch the TUI migrates the config directory (e.g. from an older location to ~/.codewhale/) via codewhale_config::migrate_config_if_needed(). If that migration fails, a non-fatal warning \"Failed to create first-run config file: {err}\" is logged and startup continues. Existing installs keep working; the new-location config may be missing or stale.","triggerScenarios":"codewhale_config::migrate_config_if_needed() returns Err during first-run bootstrap in crates/tui/src/lib.rs (~11205) — e.g. unwritable home directory, existing file at the destination blocking creation, or permission errors.","commonSituations":"Read-only or full HOME; stale config file/directory already at the target path with wrong permissions; running under a sandboxed service account without a writable home; container images with $HOME unset.","solutions":["Read the logged {err} detail and fix the filesystem cause (permissions, disk space).","Ensure $HOME points to a writable directory, or run with a writable HOME.","Remove or fix conflicting files/directories at the destination config path.","Create the config manually at ~/.codewhale/ if migration cannot run; the warning is non-fatal."],"exampleFix":"// before (unwritable)\nHOME=/nonexistent app\n// after\nHOME=/home/user app","handlingStrategy":"validation","validationCode":"let home = std::env::var(\"HOME\")?; assert_writable_dir(&home)?;","typeGuard":null,"tryCatchPattern":"match migrate_config_if_needed() { Err(err) => eprintln!(\"using existing config; migration failed: {err}\"), _ => {} }","preventionTips":["Run the app with a writable HOME.","Never run as root in a way that leaves root-owned files in the config directory.","Pre-provision ~/.codewhale/ on managed/container installs."],"tags":["config","migration","filesystem","first-run"],"backgroundTag":"file-write-failed","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}