jdx/mise · error

workspace path escapes the workspace root

Error message

workspace path {path:?} escapes the workspace root

What it means

During workspace path normalization, a ParentDir ("..") component that pops past the top of the relative path means the path escapes the workspace root. mise rejects it so resolved paths can never point outside the workspace directory.

Solutions

  1. Remove or rebalance the ".." components so the path stays under the workspace root
  2. Move the referenced file/directory into the workspace
  3. Normalize/resolve the path before writing it into config to drop redundant ".." segments

Example fix

// before
let p = Path::new("../shared/config.toml");
// after
let p = Path::new("shared/config.toml");
Defensive patterns

Strategy: validation

Validate before calling

fn path_stays_in_workspace(p: &std::path::Path) -> bool {
    let mut depth = 0usize;
    for c in p.components() {
        match c {
            std::path::Component::ParentDir => {
                if depth == 0 { return false; }
                depth -= 1;
            }
            std::path::Component::Normal(_) => depth += 1,
            _ => {}
        }
    }
    true
}

Type guard

let contained = |p: &std::path::Path| path_stays_in_workspace(p);

Try / catch

if let Err(e) = normalize_workspace_path(&p) {
    if e.to_string().contains("escapes the workspace root") {
        eprintln!("path must remain under the workspace root");
    }
}

Prevention

When it happens

Trigger: A workspace path like "../outside" or "a/../../b" where the ParentDir components exceed the Normal components, hitting the bail in the component loop.

Common situations: Glob or file patterns referencing directories outside the workspace; path joins that accidentally accumulate ".." segments.

Understand the failure class

Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/1f9a74dd950e76a1. Report an issue: GitHub.

Appendix: source

Thrown at src/task/workspace.rs:1232

    if normalized.as_os_str().is_empty() {
        normalized.push(".");
    }
    Ok(normalized)
}

fn normalize_workspace_path(path: &Path) -> Result<PathBuf> {
    if path.is_absolute() {
        bail!("workspace path {path:?} is absolute; paths must be workspace-relative");
    }

    let mut normalized = PathBuf::new();
    for component in path.components() {
        match component {
            Component::CurDir => {}
            Component::Normal(component) => normalized.push(component),
            Component::ParentDir => {
                if !normalized.pop() {
                    bail!("workspace path {path:?} escapes the workspace root");
                }
            }
            Component::RootDir | Component::Prefix(_) => {
                bail!("workspace path {path:?} is absolute; paths must be workspace-relative");
            }
        }
    }
    if normalized.as_os_str().is_empty() {
        normalized.push(".");
    }
    Ok(normalized)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[derive(Debug)]

View on GitHub (pinned to 533346cc37)