xai-org/grok-build · error
{LOCAL_WORKSPACE_HOME_DENIED}
Error message
{LOCAL_WORKSPACE_HOME_DENIED} What it means
As a safety rail, `validate_local_workspace_cwd` refuses to use the filesystem root `/` or the user's home directory as the local workspace, bailing with `LOCAL_WORKSPACE_HOME_DENIED` (session_startup.rs:517 and 522). This prevents the agent from operating on the whole home tree by accident. The check is skipped when GROK_CHAT_LOCAL_WORKSPACE_ALLOW_HOME is truthy.
Source
Thrown at crates/codegen/xai-grok-pager/src/app/session_startup.rs:522
abs.display()
)
})?;
if !canon.is_dir() {
anyhow::bail!(
"local workspace cwd must be an existing directory: {}",
canon.display()
);
}
if env_truthy(GROK_CHAT_LOCAL_WORKSPACE_ALLOW_HOME_ENV) {
return Ok(canon);
}
if canon == std::path::Path::new("/") {
anyhow::bail!("{LOCAL_WORKSPACE_HOME_DENIED}");
}
if let Some(home_path) = xai_dirs::home_dir() {
let home_canon = home_path.canonicalize().unwrap_or(home_path);
if canon == home_canon {
anyhow::bail!("{LOCAL_WORKSPACE_HOME_DENIED}");
}
}
Ok(canon)
}
/// Banner and first-run confirm for the local-workspace own and attach modes.
///
/// Skip confirm only with `GROK_CHAT_LOCAL_WORKSPACE_ACK=1` or a prior ack file.
/// Non-TTY without ACK refuses (fail closed).
#[cfg(feature = "local-workspace")]
pub fn emit_local_workspace_startup_ux(cfg: &LocalWorkspaceConfig) -> anyhow::Result<()> {
use std::io::IsTerminal;
emit_local_workspace_startup_ux_with(cfg, std::io::stdin().is_terminal())
}
/// Testable UX gate: `stdin_is_terminal` is injected.
#[cfg(feature = "local-workspace")]
pub fn emit_local_workspace_startup_ux_with(
cfg: &LocalWorkspaceConfig,
stdin_is_terminal: bool,View on GitHub (pinned to bc7f02eddd)
Solutions
- Choose a dedicated project subdirectory instead of $HOME or `/`
- Set GROK_CHAT_LOCAL_WORKSPACE_ALLOW_HOME=1 only if you truly intend home/root scope
- cd into a project directory before launching so the default cwd is not home
- Check for symlinks that canonicalize to $HOME
Example fix
// before cd ~ grok-pager --chat --local-workspace // after cd ~/projects/my-app grok-pager --chat --local-workspace
Defensive patterns
Strategy: validation
Validate before calling
fn is_denied_workspace(p: &std::path::Path) -> bool {
let canon = p.canonicalize().unwrap_or_else(|_| p.to_path_buf());
canon == std::path::Path::new("/")
|| std::env::var("HOME").ok().map(|h| std::path::PathBuf::from(h).canonicalize().unwrap_or(std::path::PathBuf::from(h))) == Some(canon.clone())
|| canon.parent().is_none()
} Try / catch
match validate_local_workspace_cwd(&cwd) {
Err(e) if e.to_string().contains("HOME_DENIED") || e.to_string().contains("denied") => {
eprintln!("pick a project subdirectory (or set GROK_CHAT_LOCAL_WORKSPACE_ALLOW_HOME=1 deliberately): {e}")
}
other => other?,
} Prevention
- Always cd into a dedicated project directory before enabling local workspace
- Never set GROK_CHAT_LOCAL_WORKSPACE_CWD to ~ or /
- Avoid symlink aliases that resolve to $HOME
- Treat GROK_CHAT_LOCAL_WORKSPACE_ALLOW_HOME as a last resort
When it happens
Trigger: Setting the workspace cwd (CLI or env) to `/`, to `$HOME` exactly, or to any path that canonicalizes to home (e.g. `/home/user`, symlinked home, `~` alone) without the allow-home env override.
Common situations: Leaving GROK_CHAT_LOCAL_WORKSPACE_CWD unset-but-enabled so it falls back to $HOME; launching from the home directory with cwd-only semantics; symlink alias resolving to home.
Related errors
- local workspace cwd must exist and be canonicalizable: {}: {
- local workspace cwd must be an existing directory: {}
- no .git file or directory found at {}
- Not a directory: {path}
- path '{}' is not within git repository '{}'
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/e733b5241af3b8f9.
Report an issue: GitHub.