zed-industries/zed · error · std::io::Error

sandbox grant path {} is not absolute

Error message

sandbox grant path {} is not absolute

What it means

Validation helper in canonical_path.rs rejecting a sandbox grant path that is not absolute. It fires when a caller passes a relative path to resolve or from_canonical on platforms whose constructors resolve paths against the process working directory, which would make the grant depend on the CWD.

Source

Thrown at crates/sandbox/src/util/canonical_path.rs:221

    /// Linux: an independent `O_PATH` descriptor to the same pinned inode,
    /// duplicated (with `O_CLOEXEC`) so a validation server can own and send it
    /// over `SCM_RIGHTS` without affecting this value's descriptor.
    #[cfg(target_os = "linux")]
    pub(crate) fn dup_fd(&self) -> io::Result<OwnedFd> {
        self.fd.as_fd().try_clone_to_owned()
    }
}

/// Reject a non-absolute grant path. Gated to the platforms whose constructors
/// resolve paths against the process working directory; on WSL/other the path is
/// a namespace-specific form that `Path::is_absolute` would misjudge, and its
/// real resolution happens WSL-side (see `crate::windows_wsl`).
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn require_absolute(path: &Path) -> io::Result<()> {
    if path.is_absolute() {
        Ok(())
    } else {
        Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            format!("sandbox grant path {} is not absolute", path.display()),
        ))
    }
}

/// Windows: enforce that a stored grant path is one of the two shapes a
/// sandboxed WSL command can name — a Windows drive path (`C:\...` or `\\?\C:\...`,
/// on NTFS) or a Linux-absolute path (`/...`, inside the WSL distro). Everything
/// else (notably `\\wsl.localhost\...` and other UNC paths, and relative paths)
/// is rejected, so an invalid grant shape can't be represented as a
/// [`CanonicalPathBuf`]. `Path::is_absolute` isn't used: it would reject a
/// perfectly valid Linux-absolute grant like `/home/me` on Windows.
#[cfg(target_os = "windows")]
fn require_windows_grant_shape(path: &Path) -> io::Result<()> {
    let text = path.to_string_lossy();
    // Linux-absolute (WSL): exactly one leading '/'.
    let is_wsl = text.starts_with('/') && !text.starts_with("//");

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Convert the grant path to an absolute path before configuring the sandbox
  2. Resolve the path against the intended base directory explicitly
  3. Check configuration files for relative write-grant paths
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/sandbox/src/util/canonical_path.rs:221 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20). Data as JSON: /api/errors/368b25b599d33bc6. Report an issue: GitHub.