{"record":{"id":"a70ae136415d3afc","repo":"xai-org/grok-build","slug":"local-workspace-requires-chat","errorCode":null,"errorMessage":"{LOCAL_WORKSPACE_REQUIRES_CHAT}","messagePattern":"\\{LOCAL_WORKSPACE_REQUIRES_CHAT\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/session_startup.rs","lineNumber":430,"sourceCode":"#[cfg(feature = \"local-workspace\")]\npub fn resolve_local_workspace_config(\n    chat: bool,\n    cli_own: Option<Option<&std::path::Path>>,\n    cli_attach: Option<&str>,\n    cli_cwd: Option<&std::path::Path>,\n) -> anyhow::Result<Option<LocalWorkspaceConfig>> {\n    let env_enable = env_truthy(GROK_CHAT_LOCAL_WORKSPACE_ENV);\n    let env_mode = env_nonempty(GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV);\n    let env_server_id = env_nonempty(GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID_ENV);\n    let env_cwd = env_nonempty(GROK_CHAT_LOCAL_WORKSPACE_CWD_ENV).map(std::path::PathBuf::from);\n    let cli_attach = cli_attach.map(str::trim).filter(|s| !s.is_empty());\n    let cli_requested = cli_own.is_some() || cli_attach.is_some();\n    let env_requested = env_enable || env_mode.is_some() || env_server_id.is_some();\n    if !cli_requested && !env_requested {\n        return Ok(None);\n    }\n    if !chat {\n        anyhow::bail!(\"{LOCAL_WORKSPACE_REQUIRES_CHAT}\");\n    }\n    let mode = if cli_attach.is_some() {\n        LocalWorkspaceMode::Attach\n    } else if cli_own.is_some() {\n        LocalWorkspaceMode::Own\n    } else if let Some(ref m) = env_mode {\n        match m.as_str() {\n            \"attach\" => LocalWorkspaceMode::Attach,\n            \"own\" => LocalWorkspaceMode::Own,\n            other => {\n                anyhow::bail!(\n                    \"invalid {GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV}={other:?}; expected own|attach\"\n                )\n            }\n        }\n    } else if env_server_id.is_some() {\n        LocalWorkspaceMode::Attach\n    } else {","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/session_startup.rs#L412-L448","documentation":"`resolve_local_workspace_config` only permits the local-workspace feature inside chat mode. If any local-workspace request is present (CLI `--local-workspace[-own|-attach]` or env `GROK_CHAT_LOCAL_WORKSPACE*`) but the `chat` argument is false, it bails with `LOCAL_WORKSPACE_REQUIRES_CHAT` (session_startup.rs:430).","triggerScenarios":"Calling `resolve_local_workspace_config(false, Some(..), ..)` or running the binary with local-workspace CLI/env options set while `--chat` is absent; `resolve_local_workspace_requires_chat` explicitly exercises this path.","commonSituations":"Env vars like GROK_CHAT_LOCAL_WORKSPACE exported globally in a shell profile, then running a non-chat command; forgetting `--chat` while passing local-workspace flags.","solutions":["Add `--chat` (or pass chat=true) when requesting a local workspace","Unset GROK_CHAT_LOCAL_WORKSPACE* env vars for non-chat runs","Remove local-workspace flags from non-chat command lines/scripts"],"exampleFix":"// before\ngrok-pager --local-workspace-own\n// after\ngrok-pager --chat --local-workspace-own","handlingStrategy":"validation","validationCode":"fn local_workspace_requested(cli_own: bool, cli_attach: bool) -> bool {\n    cli_own || cli_attach\n        || std::env::var_os(\"GROK_CHAT_LOCAL_WORKSPACE\").is_some_and(|v| v == \"1\" || v == \"true\")\n        || std::env::var_os(\"GROK_CHAT_LOCAL_WORKSPACE_MODE\").is_some()\n        || std::env::var_os(\"GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID\").is_some()\n}\n// refuse early: if local_workspace_requested(..) && !chat { return Err(..) }","typeGuard":null,"tryCatchPattern":"match resolve_local_workspace_config(chat, own, attach, cwd) {\n    Err(e) if e.to_string().contains(\"chat\") => eprintln!(\"enable --chat to use local workspace: {e}\"),\n    other => other?,\n}","preventionTips":["Only export GROK_CHAT_LOCAL_WORKSPACE* in chat-specific profiles","Always pair local-workspace flags with --chat","Unset local-workspace env vars in non-chat shells/scripts"],"tags":["cli","local-workspace","env","configuration"],"backgroundTag":"missing-chat-mode-flag","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}