xai-org/grok-build · error

{LOCAL_WORKSPACE_REQUIRES_CHAT}

Error message

{LOCAL_WORKSPACE_REQUIRES_CHAT}

What it means

`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).

Source

Thrown at crates/codegen/xai-grok-pager/src/app/session_startup.rs:430

#[cfg(feature = "local-workspace")]
pub fn resolve_local_workspace_config(
    chat: bool,
    cli_own: Option<Option<&std::path::Path>>,
    cli_attach: Option<&str>,
    cli_cwd: Option<&std::path::Path>,
) -> anyhow::Result<Option<LocalWorkspaceConfig>> {
    let env_enable = env_truthy(GROK_CHAT_LOCAL_WORKSPACE_ENV);
    let env_mode = env_nonempty(GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV);
    let env_server_id = env_nonempty(GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID_ENV);
    let env_cwd = env_nonempty(GROK_CHAT_LOCAL_WORKSPACE_CWD_ENV).map(std::path::PathBuf::from);
    let cli_attach = cli_attach.map(str::trim).filter(|s| !s.is_empty());
    let cli_requested = cli_own.is_some() || cli_attach.is_some();
    let env_requested = env_enable || env_mode.is_some() || env_server_id.is_some();
    if !cli_requested && !env_requested {
        return Ok(None);
    }
    if !chat {
        anyhow::bail!("{LOCAL_WORKSPACE_REQUIRES_CHAT}");
    }
    let mode = if cli_attach.is_some() {
        LocalWorkspaceMode::Attach
    } else if cli_own.is_some() {
        LocalWorkspaceMode::Own
    } else if let Some(ref m) = env_mode {
        match m.as_str() {
            "attach" => LocalWorkspaceMode::Attach,
            "own" => LocalWorkspaceMode::Own,
            other => {
                anyhow::bail!(
                    "invalid {GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV}={other:?}; expected own|attach"
                )
            }
        }
    } else if env_server_id.is_some() {
        LocalWorkspaceMode::Attach
    } else {

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Add `--chat` (or pass chat=true) when requesting a local workspace
  2. Unset GROK_CHAT_LOCAL_WORKSPACE* env vars for non-chat runs
  3. Remove local-workspace flags from non-chat command lines/scripts

Example fix

// before
grok-pager --local-workspace-own
// after
grok-pager --chat --local-workspace-own
Defensive patterns

Strategy: validation

Validate before calling

fn local_workspace_requested(cli_own: bool, cli_attach: bool) -> bool {
    cli_own || cli_attach
        || std::env::var_os("GROK_CHAT_LOCAL_WORKSPACE").is_some_and(|v| v == "1" || v == "true")
        || std::env::var_os("GROK_CHAT_LOCAL_WORKSPACE_MODE").is_some()
        || std::env::var_os("GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID").is_some()
}
// refuse early: if local_workspace_requested(..) && !chat { return Err(..) }

Try / catch

match resolve_local_workspace_config(chat, own, attach, cwd) {
    Err(e) if e.to_string().contains("chat") => eprintln!("enable --chat to use local workspace: {e}"),
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/a70ae136415d3afc. Report an issue: GitHub.