jdx/mise · error · eyre::Report

managed file parent does not exist

Error message

managed file parent does not exist: {}

What it means

While validating a managed file's destination, the library stats the parent directory. If the parent does not exist (`ErrorKind::NotFound`), it fails with this error instead of implicitly creating directories — managed file installation does not auto-create arbitrary parent trees.

Solutions

  1. Create the parent directory first with `mkdir -p` / `fs::create_dir_all(parent)`
  2. Check the configured path for typos (wrong directory name, missing mount point)
  3. Ensure any volume/mount the path lives on is mounted before running the operation

Example fix

// before
install_managed_file(Path::new("/opt/myapp/config/app.conf"), ...)?; // /opt/myapp/config missing
// after
std::fs::create_dir_all("/opt/myapp/config")?;
install_managed_file(Path::new("/opt/myapp/config/app.conf"), ...)?;
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_parent_exists(path: &std::path::Path) -> std::io::Result<()> {
    if let Some(parent) = path.parent() {
        std::fs::create_dir_all(parent)?;
    }
    Ok(())
}

Type guard

fn parent_exists(path: &std::path::Path) -> bool {
    path.parent().map_or(false, |p| p.exists())
}

Try / catch

match result {
    Err(e) if e.to_string().contains("parent does not exist") => {
        std::fs::create_dir_all(expected_parent)?;
        retry_operation()?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling a managed-file write/install whose parent directory has never been created — e.g. path "/opt/myapp/config/app.conf" where neither "config" nor "myapp" exists on disk.

Common situations: First-time deployment on a fresh machine where the app's config directories were never provisioned; typos in configured paths; container images missing expected directories.

Related errors


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

Appendix: source

Thrown at src/system/managed_files.rs:1538

fn write_file(
    path: &Path,
    content: &[u8],
    owner: Option<&str>,
    group: Option<&str>,
    mode: u32,
    replace: bool,
) -> Result<()> {
    let parent = path
        .parent()
        .ok_or_else(|| eyre!("managed file has no parent: {}", path.display()))?;
    match fs::metadata(parent) {
        Ok(metadata) if metadata.is_dir() => {}
        Ok(_) => bail!(
            "managed file parent is not a directory: {}",
            parent.display()
        ),
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
            bail!("managed file parent does not exist: {}", parent.display())
        }
        Err(error) => return Err(error.into()),
    }
    // Prepare the complete replacement before mutating the destination. In
    // particular, a metadata permission error must leave the old path intact.
    let mut temporary = tempfile::NamedTempFile::new_in(parent)?;
    temporary.write_all(content)?;
    set_metadata(temporary.path(), owner, group, mode)?;
    temporary.as_file_mut().sync_all()?;
    match fs::symlink_metadata(path) {
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
        Err(error) => return Err(error.into()),
        Ok(metadata) if metadata.file_type().is_file() => {}
        Ok(_) if !replace => {
            bail!("refusing to replace non-file path: {}", path.display())
        }
        Ok(metadata) if metadata.file_type().is_dir() => {
            fs::remove_dir(path).wrap_err_with(|| {

View on GitHub (pinned to 533346cc37)