BoundaryML/baml · error
failed to install {} into {}
Error message
failed to install {} into {} What it means
`baml agent` skill installation failed at the final step of swapping the freshly prepared directory into place: fs::rename(next_dir, final_dir) returned an error, which is wrapped with context naming the skill and target directory. Commonly this is a cross-filesystem rename, an existing non-empty target, or a filesystem permission problem.
Source
Thrown at baml_language/crates/baml_cli/src/agent_command.rs:265
format!("failed to clear old-skill slot {}", archive_dir.display())
})?;
}
if let Some(parent) = archive_dir.parent() {
fs::create_dir_all(parent)
.with_context(|| format!("failed to create {}", parent.display()))?;
}
fs::rename(&final_dir, &archive_dir).with_context(|| {
format!(
"failed to archive existing {} into {}",
final_dir.display(),
archive_dir.display()
)
})?;
archive = Some(archive_dir);
}
if let Err(err) = fs::rename(&next_dir, &final_dir) {
let mut error = anyhow!(err).context(format!(
"failed to install {} into {}",
skill.name,
final_dir.display()
));
if let Some(archive_dir) = archive {
if final_dir.exists() {
error = error.context(format!(
"previous {} skill remains at {}",
skill.name,
archive_dir.display()
));
} else if let Err(restore_err) = fs::rename(&archive_dir, &final_dir) {
error = error.context(format!(
"failed to restore previous {} skill from {} to {}: {restore_err}",
skill.name,
archive_dir.display(),
final_dir.display()
));View on GitHub (pinned to bd85ce9dee)
Solutions
- Check write permissions on the target skills directory and its parent.
- Ensure the staging dir and final dir are on the same filesystem (or copy+delete instead of rename).
- Remove or back up the existing destination directory if it is blocking the rename.
- Close processes locking the destination (editors, sync clients, antivirus).
Example fix
// before
fs::rename(&next_dir, &final_dir)?;
// after: fall back to copy when rename crosses devices
match fs::rename(&next_dir, &final_dir) {
Ok(()) => {},
Err(e) if e.kind() == std::io::ErrorKind::CrossesDevices => {
copy_dir_all(&next_dir, &final_dir)?;
fs::remove_dir_all(&next_dir)?;
}
Err(e) => return Err(e.into()),
} Defensive patterns
Strategy: fallback
Validate before calling
// pre-flight checks before install
let dest = &final_dir;
assert!(dest.parent().map(|p| p.exists()).unwrap_or(false));
// check writability
std::fs::OpenOptions::new().write(true).open(dest.parent().join(".probe")).is_ok(); Try / catch
match fs::rename(&next_dir, &final_dir) {
Ok(()) => {},
Err(e) if e.kind() == std::io::ErrorKind::CrossesDevices => {
copy_dir_all(&next_dir, &final_dir)?;
fs::remove_dir_all(&next_dir)?;
}
Err(e) => return Err(anyhow!(e).context(format!("failed to install {}", skill.name))),
} Prevention
- Stage temp dirs on the same filesystem/volume as the destination.
- Ensure the skills directory is writable by the running user.
- Disable sync/AV tools locking the destination during install.
- Remove stale destination directories before reinstalling.
When it happens
Trigger: install_skills_to -> replace_skill_dir calling fs::rename on the staged skill dir when the destination path exists on a different filesystem/mount, is not writable, or cannot be replaced.
Common situations: Skills directory on a different mount/DFS than the temp staging dir; read-only or root-owned ~/.baml (or configured skills dir); antivirus/indexer holding the destination open on Windows.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- access error: {message}
- ErrCacheDir
- failed create destination %s: %w
- IO error: {0}
- toolchain binary is not executable: {}{origin}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/6ed9ce67ce4ac41e.
Report an issue: GitHub.