jdx/mise · error
invalid cleanup target
Error message
invalid cleanup target {} What it means
During post-install cleanup of apk transients, `reject_symlink_components` re-validates each cleanup target path relative to the rootfs. Any component that is not a plain `Normal` component (e.g. `..`, `/`, or a prefix) makes the target unsafe, so mise bails with this error.
Solutions
- Inspect the apk database/installed paths inside the rootfs for malformed entries and repair them.
- Rebuild from a clean, known-good Alpine/Wolfi base image.
- If reproducible with a normal config, file a mise bug with the config and base image details.
Defensive patterns
Strategy: try-catch
Try / catch
try { await miseOciBuild(cfg) } catch (e) { if (String(e).includes('invalid cleanup target')) { console.error(' apk database produced a malformed path; rebuild from a clean base image.'); process.exit(1); } throw e; } Prevention
- Use official, unmodified Alpine/Wolfi base images.
- Avoid hand-editing the rootfs or apk database between build steps.
- Report reproducible occurrences to mise as a bug with config and base image.
When it happens
Trigger: `clean_apk_transients` computes a cleanup path whose relative form against the rootfs contains non-normal components — essentially a malformed or escaping path reaching the cleanup stage.
Common situations: Corrupted or hand-edited apk database paths; unusual symlinks/paths produced by a broken package; a mise internal bug rather than user configuration.
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
- refusing cleanup through symlink component
- brew-cask: app target
- brew-cask: binary target
- brew-cask: generic artifact source is not contained by the…
- brew-cask: invalid app source
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/3897b7825fd6c5ce.
Report an issue: GitHub.
Appendix: source
Thrown at src/oci/packages.rs:557
let cache = rootfs.join("var/cache/apk");
let log = rootfs.join("var/log/apk.log");
reject_symlink_components(rootfs, &cache)?;
reject_symlink_components(rootfs, &log)?;
remove_dir_children(&cache)?;
remove_path(&log)
}
/// Reject a cleanup target when it or any path component below `rootfs` is a
/// symlink. OCI package layers are untrusted, so following one during cleanup
/// could remove files outside the layer root.
fn reject_symlink_components(rootfs: &Path, target: &Path) -> Result<()> {
let relative = target
.strip_prefix(rootfs)
.wrap_err_with(|| format!("cleanup target {} is outside rootfs", target.display()))?;
let mut current = rootfs.to_path_buf();
for component in relative.components() {
let std::path::Component::Normal(component) = component else {
bail!("invalid cleanup target {}", target.display());
};
current.push(component);
match fs::symlink_metadata(¤t) {
Ok(metadata) if metadata.file_type().is_symlink() => {
bail!(
"refusing cleanup through symlink component {}",
current.display()
);
}
Ok(_) => {}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(()),
Err(err) => {
return Err(err)
.wrap_err_with(|| format!("reading metadata for {}", current.display()));
}
}
}
Ok(())View on GitHub (pinned to 533346cc37)