jdx/mise · error
brew-cask: refusing to remove generic artifact outside {}: {
Error message
brew-cask: refusing to remove generic artifact outside {}: {} What it means
On upgrade or uninstall, obsolete generic artifacts (recorded from a previous install but absent from the cask's current target list) are deleted. Before each removal mise re-verifies via path_starts_with_resolved_root that the recorded path still resolves inside the current Homebrew prefix; refusal protects against deleting files that now live outside the managed prefix.
Source
Thrown at src/system/packages/brew/cask.rs:2417
};
Ok(receipt
.targets
.into_iter()
.filter(|record| receipt.generic.contains(&record.path))
.collect())
}
fn remove_obsolete_generic_artifacts(
previous_targets: &[CaskTargetRecord],
current_targets: &[PathBuf],
) -> Result<()> {
let prefix = prefix::prefix();
for record in previous_targets {
if current_targets.contains(&record.path) || !cask_target_record_matches(record)? {
continue;
}
if !path_starts_with_resolved_root(&record.path, &prefix) {
bail!(
"brew-cask: refusing to remove generic artifact outside {}: {}",
prefix.display(),
record.path.display()
);
}
if let Err(err) = remove_trusted_generic_target(&record.path) {
warn!(
"brew-cask: leaving obsolete generic artifact {} because its parent directories are mutable: {err:#}",
record.path.display()
);
}
}
Ok(())
}
fn remove_trusted_generic_target(target: &Path) -> Result<()> {
let expected_parent = resolved_parent(target)?;
match remove_trusted_generic_target_from(target, &expected_parent) {View on GitHub (pinned to 9dcfcaa0dc)
Solutions
- Re-run the command with the same HOMEBREW_PREFIX that was active when the artifact was installed
- If the prefix change is intentional, remove the obsolete artifact manually (path shown in the error) and clear the stale target record, then reinstall under the new prefix
- Reinstall the cask under the current prefix so its records regenerate
Example fix
# before: prefix changed since install HOMEBREW_PREFIX=/opt/homebrew mise uninstall foo # refuses # after: use the original prefix for the uninstall HOMEBREW_PREFIX=/usr/local mise uninstall foo
Defensive patterns
Strategy: validation
Validate before calling
let prefix = homebrew_prefix();
for record in previous_targets {
if !path_starts_with_resolved_root(&record.path, &prefix) {
// prefix changed since install: migrate or clear the record before running the uninstall/upgrade
eprintln!("stale target record outside prefix: {}", record.path.display());
}
} Prevention
- Keep HOMEBREW_PREFIX stable, or reinstall casks immediately after changing it
- Never hand-edit recorded target paths
- Run uninstalls with the same prefix that was active at install time
When it happens
Trigger: HOMEBREW_PREFIX changed between the install that recorded the target and the current run; the prefix's symlink structure changed so the recorded path resolves differently; a hand-edited or corrupted target record.
Common situations: Switching prefixes (e.g. /usr/local to /opt/homebrew after an architecture migration) without reinstalling casks; moving a custom prefix; restoring a prefix from backup with different symlinks.
Related errors
- brew-cask: refusing generic artifact copy outside Homebrew p
- brew-cask: generic artifact target '{}' must stay below {}
- brew-cask: binary target '{}' must be under {}
- install from exe
- mise outdated --monorepo is not implemented yet
AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17).
Data as JSON: /api/errors/9bdee3a0479362ef.
Report an issue: GitHub.