xai-org/grok-build · error
invalid {GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV}={other:?}; expe
Error message
invalid {GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV}={other:?}; expected own|attach What it means
The env var `GROK_CHAT_LOCAL_WORKSPACE_MODE` must be exactly `own` or `attach`. Any other non-empty value causes `resolve_local_workspace_config` to bail with `invalid GROK_CHAT_LOCAL_WORKSPACE_MODE=<value>; expected own|attach` (session_startup.rs:441).
Source
Thrown at crates/codegen/xai-grok-pager/src/app/session_startup.rs:441
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 {
LocalWorkspaceMode::Own
};
let cwd = cli_cwd
.map(std::path::Path::to_path_buf)
.or_else(|| cli_own.and_then(|inner| inner.map(std::path::Path::to_path_buf)))
.or(env_cwd)
.unwrap_or_else(|| {
std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from("."))
});
let cwd = if cwd.is_absolute() {
cwdView on GitHub (pinned to bc7f02eddd)
Solutions
- Set the env var to exactly `own` or `attach` (lowercase, no whitespace)
- Unset GROK_CHAT_LOCAL_WORKSPACE_MODE and rely on CLI flags instead
- Check the value for typos/case with `echo $GROK_CHAT_LOCAL_WORKSPACE_MODE`
Example fix
// before export GROK_CHAT_LOCAL_WORKSPACE_MODE=Own // after export GROK_CHAT_LOCAL_WORKSPACE_MODE=own
Defensive patterns
Strategy: validation
Validate before calling
fn valid_ws_mode() -> Result<(), String> {
match std::env::var("GROK_CHAT_LOCAL_WORKSPACE_MODE") {
Ok(m) if matches!(m.trim(), "own" | "attach") => Ok(()),
Ok(m) => Err(format!("invalid GROK_CHAT_LOCAL_WORKSPACE_MODE={m:?}; expected own|attach")),
Err(_) => Ok(()),
}
} Type guard
fn is_valid_mode(m: &str) -> bool { matches!(m, "own" | "attach") } Try / catch
match resolve_local_workspace_config(chat, own, attach, cwd) {
Err(e) if e.to_string().contains("expected own|attach") => {
eprintln!("fix GROK_CHAT_LOCAL_WORKSPACE_MODE to 'own' or 'attach': {e}")
}
other => other?,
} Prevention
- Use lowercase 'own'/'attach' only
- Quote env values in shell profiles to avoid stray characters
- Validate env vars in entrypoint scripts before launching the tool
When it happens
Trigger: Setting GROK_CHAT_LOCAL_WORKSPACE_MODE to a typo, different casing (e.g. `Own`, `ATTACH`), or an unsupported value like `shared` while any local-workspace request is active.
Common situations: Copy-pasted config from docs of another tool; shell profile exports with wrong casing; YAML/JSON values pasted with surrounding characters.
Related errors
- {LOCAL_WORKSPACE_REQUIRES_CHAT}
- {LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID}
- invalid worktree id from dest: {worktree_id}
- invalid worktree id {:?}
- local workspace cwd must exist and be canonicalizable: {}: {
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/a7de0799bc1f20cf.
Report an issue: GitHub.