jdx/mise · error

relative remote mise path escapes the staged project

Error message

relative remote mise path escapes the staged project: {command:?}

What it means

Relative remote mise paths are resolved against the staged project directory, and `..` components that would pop past the project root are rejected. This error means the configured relative path contains enough `..` segments to escape the staging area, which mise refuses as a path-traversal safety measure.

Solutions

  1. Use an absolute path (e.g. `/usr/local/bin/mise`) for binaries outside the staged project
  2. Use a `~/`-prefixed path for home-relative binaries
  3. Rewrite the relative path to stay within the project directory (no leading `..` escapes)

Example fix

// before
remote_mise = "../../usr/local/bin/mise"
// after
remote_mise = "/usr/local/bin/mise"
Defensive patterns

Strategy: validation

Validate before calling

// reject relative paths that escape via '..'
fn escapes_project(p: &str) -> bool {
    let mut depth = 0i32;
    for c in p.split('/') {
        match c {
            "" | "." => {}
            ".." => { depth -= 1; if depth < 0 { return true; } }
            _ => depth += 1,
        }
    }
    false
}

Prevention

When it happens

Trigger: Normalizing a relative remote mise path during provision; the split-on-'/' loop pops an empty component stack on a `..` (e.g. `../bin/mise`, `a/../../mise`).

Common situations: User assumes the base is the home directory or /usr, not the staged project, and writes `../../usr/bin/mise`; config copied from a non-staged setup.

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/71bfd941be12ee6a. Report an issue: GitHub.

Appendix: source

Thrown at src/system/remote.rs:1254

) -> Result<String> {
    if command.starts_with('/') {
        return Ok(command.to_string());
    }
    if let Some(suffix) = command.strip_prefix("~/") {
        if suffix.is_empty() {
            bail!("remote mise path does not name an executable: {command:?}");
        }
        let home = remote_home.ok_or_else(|| eyre!("remote login home was not resolved"))?;
        return Ok(format!("{}/{suffix}", home.trim_end_matches('/')));
    }

    let mut components = Vec::new();
    for component in command.split('/') {
        match component {
            "" | "." => {}
            ".." => {
                if components.pop().is_none() {
                    bail!("relative remote mise path escapes the staged project: {command:?}");
                }
            }
            component => components.push(component),
        }
    }
    if components.is_empty() {
        bail!("relative remote mise path does not name an executable: {command:?}");
    }
    Ok(format!("{project}/{}", components.join("/")))
}

fn remote_mise_find_script() -> &'static str {
    r#"mise_path=$(command -v mise 2>/dev/null || true)
case "$mise_path" in /*) ;; *) mise_path= ;; esac
if [ -z "$mise_path" ]; then
  for candidate in "$HOME/.local/bin/mise" "$HOME/.local/share/mise/bin/mise" "$HOME/.cargo/bin/mise" /usr/local/bin/mise /opt/homebrew/bin/mise; do
    if [ -x "$candidate" ]; then
      mise_path=$candidate

View on GitHub (pinned to 533346cc37)