{"record":{"id":"80cdf323f3f6f7ac","repo":"xai-org/grok-build","slug":"failed-to-create-agent-config-e","errorCode":null,"errorMessage":"Failed to create agent config: {e}","messagePattern":"Failed to create agent config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager-bin/src/main.rs","lineNumber":598,"sourceCode":"        ClientMode::Stdio,\n        ClientCapabilities::default(),\n    )\n    .await\n    .map_err(|e| {\n        anyhow::anyhow!(\n            \"no running leader for this environment ({e}). \\\n             Start a grok session, or run `grok workspace start`.\"\n        )\n    })\n}\n#[tracing::instrument(level = \"debug\", skip_all)]\nasync fn workspace_control(\n    target: &LeaderTargetArgs,\n    json: bool,\n    command: ControlCommand,\n) -> Result<()> {\n    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)","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager-bin/src/main.rs#L580-L616","documentation":"workspace_control loads the agent configuration strictly from disk (no network/remote refresh) before connecting to the leader. If load_agent_config_disk_only fails — missing config file, invalid TOML, unreadable permissions — the error is wrapped as \"Failed to create agent config: {e}\". No leader connection is attempted.","triggerScenarios":"Calling workspace_control when load_agent_config_disk_only returns Err: config file absent at the expected path, TOML parse error, or filesystem permission denial.","commonSituations":"Fresh machine where `grok` was never configured (no on-disk config); hand-edited config.toml with syntax errors; config owned by another user or HOME/XDG env vars pointing elsewhere.","solutions":["Read the wrapped {e} to see whether the file is missing, invalid, or unreadable","Run the normal grok onboarding/auth flow once to generate the on-disk config","Fix TOML syntax errors in the config file (validate with a TOML linter)","Check file permissions and that HOME/XDG_CONFIG env vars point at the directory containing the config"],"exampleFix":"// before\n$ grok workspace list   # fails: no ~/.config/grok/config.toml on new machine\n// after\n$ grok auth login        # generates on-disk config\n$ grok workspace list","handlingStrategy":"validation","validationCode":"let cfg_path = config_dir().join(\"config.toml\");\nif !cfg_path.exists() {\n    return Err(anyhow!(\"agent config missing at {} — run `grok auth login` first\", cfg_path.display()));\n}\n// parse-check without side effects\nlet _raw = std::fs::read_to_string(&cfg_path)?;\nlet _: toml::Value = toml::from_str(&_raw)?;","typeGuard":"fn config_readable(path: &std::path::Path) -> bool {\n    std::fs::read_to_string(path)\n        .ok()\n        .and_then(|s| toml::from_str::<toml::Value>(&s).ok())\n        .is_some()\n}","tryCatchPattern":"match workspace_control(&target, json, cmd).await {\n    Err(e) if e.to_string().contains(\"Failed to create agent config\") => {\n        eprintln!(\"config problem: {e:#}. Fix or regenerate the on-disk config.\");\n        std::process::exit(1);\n    }\n    other => other,\n}","preventionTips":["Run grok onboarding once so a valid on-disk config exists","Validate config.toml with a TOML linter after hand edits","Keep config file permissions readable by the running user","Avoid changing HOME/XDG_CONFIG env vars between grok invocations"],"tags":["configuration","toml","filesystem","cli"],"backgroundTag":"config-load-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}