{"record":{"id":"047999084a3f37ff","repo":"xai-org/grok-build","slug":"failed-to-load-config-e","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-bin/src/main.rs","lineNumber":615,"sourceCode":"    let agent_config = xai_grok_shell::config::load_agent_config_disk_only()\n        .map_err(|e| anyhow::anyhow!(\"Failed to create agent config: {e}\"))?;\n    let client = connect_workspace_control(&agent_config, target).await?;\n    ensure_workspace_caps(client.registration())?;\n    let payload = client.send_control(command).await??;\n    render_workspace_payload(&payload, json);\n    client.cancel();\n    Ok(())\n}\n#[tracing::instrument(level = \"debug\", skip_all)]\nasync fn workspace_start(\n    args: WorkspaceStartArgs,\n    restart: bool,\n    remote_settings: Option<xai_grok_shell::util::config::RemoteSettings>,\n) -> Result<()> {\n    use xai_grok_shell::auth::ensure_authenticated;\n    xai_grok_shell::util::config::set_remote_campaigns_from_settings(remote_settings.as_ref());\n    let raw_config = xai_grok_shell::config::load_effective_config()\n        .map_err(|e| anyhow::anyhow!(\"Failed to load config: {e}\"))?;\n    let agent_config = AgentConfig::new_from_toml_cfg(&raw_config)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create agent config: {e}\"))?;\n    let (use_leader, _) = resolve_use_leader(\n        args.leader,\n        args.no_leader,\n        &raw_config,\n        remote_settings.as_ref(),\n        true,\n        xai_grok_sandbox::requested_confinement_profile(),\n    );\n    if !use_leader {\n        anyhow::bail!(\n            \"`grok workspace` requires leader mode (the workspace is shared via the leader).\\n\\\n             Enable it with `[cli] use_leader = true` in ~/.grok/config.toml, or pass --leader.\"\n        );\n    }\n    ensure_authenticated(\n        &agent_config.grok_com_config,","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager-bin/src/main.rs#L597-L633","documentation":"workspace_start loads the full effective configuration (load_effective_config) and wraps any failure as \"Failed to load config: {e}\". Unlike the disk-only loader, this may merge remote/derived settings, so failures include on-disk problems plus errors from computing the effective view. Startup aborts before resolving leader mode.","triggerScenarios":"Calling workspace_start when load_effective_config returns Err: missing base config, unparsable TOML, or errors while applying overrides/remote settings to build the effective config.","commonSituations":"Corrupt or hand-edited config after an upgrade introduced new required keys; conflicting overrides producing an invalid effective config; unreadable config file or wrong HOME/XDG paths.","solutions":["Inspect the wrapped {e} for the concrete load failure (file vs parse vs merge)","Fix TOML syntax or invalid values in the config, or restore a known-good backup","Re-run grok onboarding/auth to regenerate a valid base config","Verify HOME/XDG environment variables point to the intended config directory"],"exampleFix":"// before\n# ~/.config/grok/config.toml\nmodel = \n// after\n# ~/.config/grok/config.toml\nmodel = \"grok-4\"   # valid TOML value","handlingStrategy":"validation","validationCode":"let cfg_path = config_dir().join(\"config.toml\");\nif !cfg_path.exists() {\n    return Err(anyhow!(\"config not found at {} — run onboarding first\", cfg_path.display()));\n}\nlet raw = std::fs::read_to_string(&cfg_path)?;\nlet _: toml::Value = toml::from_str(&raw)?; // catch parse errors before workspace_start","typeGuard":"fn effective_config_loadable() -> bool {\n    xai_grok_shell::config::load_effective_config().is_ok()\n}","tryCatchPattern":"match workspace_start(&args, restart, remote_settings).await {\n    Err(e) if e.to_string().contains(\"Failed to load config\") => {\n        eprintln!(\"config load failed: {e:#}. Restore or fix config.toml.\");\n        std::process::exit(1);\n    }\n    other => other,\n}","preventionTips":["Back up a known-good config before editing","Run a TOML syntax check after manual edits and after upgrades","Re-run onboarding/auth if required keys are missing post-upgrade","Pin HOME/XDG paths consistently in scripts and CI"],"tags":["configuration","toml","cli","startup"],"backgroundTag":"config-load-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}