{"record":{"id":"f86bdd439554670a","repo":"xai-org/grok-build","slug":"failed-to-load-config-e-f86bdd","errorCode":null,"errorMessage":"Failed to load config: {e}","messagePattern":"Failed to load config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/mod.rs","lineNumber":617,"sourceCode":"}\n/// Main entry point: connect to agent, init terminal, run event loop, restore.\n///\n/// If a session ID is provided via `--resume` / `--load` / `--continue`, the pager skips the welcome screen and immediately loads that session.\n/// The load replays the session's history; sessions not found locally are restored from remote storage.\n///\n/// Returns `Ok(true)` when the user accepted a pending update.\n/// The caller should print a message telling the user to relaunch `grok`.\npub async fn run(\n    mut args: PagerArgs,\n    bg_update_rx: Option<\n        tokio::sync::oneshot::Receiver<Option<xai_grok_update::auto_update::UpdateAvailable>>,\n    >,\n) -> anyhow::Result<bool> {\n    let screen_mode_override = screen_mode_relaunch::take_screen_mode_env_override();\n    let cancel = CancellationToken::new();\n    let startup_start = std::time::Instant::now();\n    let raw_config = xai_grok_shell::config::load_effective_config()\n        .map_err(|e| anyhow::anyhow!(\"Failed to load config: {e}\"))?;\n    let grok_com_config = match xai_grok_shell::agent::config::Config::new_from_toml_cfg(\n        &raw_config,\n    ) {\n        Ok(c) => c.grok_com_config,\n        Err(e) => {\n            tracing::warn!(error = %e, \"failed to parse config for auth refresh, using defaults\");\n            xai_grok_shell::auth::GrokComConfig::default()\n        }\n    };\n    if matches!(\n        xai_grok_shell::auth::maybe_run_pre_tui_external_login(\n            &grok_com_config,\n            args.force_login,\n            io::stdin().is_terminal(),\n        )\n        .await?,\n        xai_grok_shell::auth::PreTuiLoginOutcome::SignedIn(_)\n    ) {","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/mod.rs#L599-L635","documentation":"During pager startup, load_effective_config() reads and merges the effective configuration (files + env). Any error it returns is wrapped with this message and propagated as the run's fatal error, because the app cannot start without configuration.","triggerScenarios":"Calling the startup entry point while load_effective_config() fails: malformed TOML in the config file, unreadable file (permissions), invalid env-var overrides, or a bad path given via environment.","commonSituations":"Typos or invalid syntax in the grok config TOML after a manual edit or version upgrade that changed the schema; XDG_CONFIG_HOME pointing somewhere unwritable; config file owned by root after running with sudo.","solutions":["Read the inner error after 'Failed to load config:' — it names the file/field that failed","Validate the config TOML syntax (e.g. with a TOML linter) and fix schema mismatches","Check file permissions on the config path ($XDG_CONFIG_HOME or ~/.config) and fix ownership","Temporarily move the config file aside to confirm it is the source, then re-add settings incrementally"],"exampleFix":"// before: invalid key from an older schema\nmodel = \"grok-3\"\nmax_tokin = 4096\n// after: corrected key\nmodel = \"grok-3\"\nmax_tokens = 4096","handlingStrategy":"validation","validationCode":"// pre-flight config check\nfn config_ok() -> bool {\n    let path = std::env::var(\"GROK_CONFIG\")\n        .map(std::path::PathBuf::from)\n        .unwrap_or_else(|_| dirs::config_dir().unwrap().join(\"grok/config.toml\"));\n    match std::fs::read_to_string(&path) {\n        Ok(s) => s.parse::<toml::Value>().is_ok(),\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match run().await {\n    Err(e) if e.to_string().starts_with(\"Failed to load config:\") => {\n        eprintln!(\"Fix your config first: {e:#}\");\n        std::process::exit(2);\n    }\n    other => other.expect(\"run\"),\n}","preventionTips":["Validate config.toml with a TOML parser after every manual edit","Keep config under version control to spot accidental schema changes","Never run the app as root such that config files change ownership","Read release notes before upgrading: config schema keys may change"],"tags":["config","startup","io"],"backgroundTag":"config-load-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}