zed-industries/zed · error · anyhow::Error

cannot write to path {resolved:?}

Error message

cannot write to path {resolved:?}

What it means

writeable_path_from_extension cannot produce a writable location for {resolved}: the canonicalization walk (walking parents until an existing ancestor canonicalizes) combined with tail components yielded a path that fails the final writability/containment check. Typically the resolved path is outside the extension work dir or on a read-only/missing parent, so the write is refused.

Source

Thrown at crates/extension_host/src/wasm_host.rs:808

        let mut existing = normalized.as_path();
        let mut tail_components = Vec::new();
        let canonical_prefix = loop {
            match self.fs.canonicalize(existing).await {
                Ok(canonical) => break canonical,
                Err(_) => {
                    if let Some(file_name) = existing.file_name() {
                        tail_components.push(file_name.to_owned());
                    }
                    existing = existing
                        .parent()
                        .context(format!("cannot resolve path {path:?}"))?;
                }
            }
        };

        let mut resolved = canonical_prefix;
        for component in tail_components.into_iter().rev() {
            resolved.push(component);
        }

        anyhow::ensure!(
            resolved.starts_with(&extension_work_dir),
            "cannot write to path {resolved:?}",
        );
        Ok(resolved)
    }
}

pub fn parse_wasm_extension_version(extension_id: &str, wasm_bytes: &[u8]) -> Result<Version> {
    let mut version = None;

    for part in wasmparser::Parser::new(0).parse_all(wasm_bytes) {
        if let wasmparser::Payload::CustomSection(s) =
            part.context("error parsing wasm extension")?
            && s.name() == "zed:api-version"
        {

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Ensure every parent directory of the target exists (create the work dir first) before writing
  2. Keep the requested path inside the extension's work directory and avoid symlinks pointing outside it
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/extension_host/src/wasm_host.rs:799 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/96e370d3c60002c1. Report an issue: GitHub.