{"record":{"id":"6ed9ce67ce4ac41e","repo":"BoundaryML/baml","slug":"failed-to-install-into","errorCode":null,"errorMessage":"failed to install {} into {}","messagePattern":"failed to install (.+?) into (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/agent_command.rs","lineNumber":265,"sourceCode":"                format!(\"failed to clear old-skill slot {}\", archive_dir.display())\n            })?;\n        }\n        if let Some(parent) = archive_dir.parent() {\n            fs::create_dir_all(parent)\n                .with_context(|| format!(\"failed to create {}\", parent.display()))?;\n        }\n        fs::rename(&final_dir, &archive_dir).with_context(|| {\n            format!(\n                \"failed to archive existing {} into {}\",\n                final_dir.display(),\n                archive_dir.display()\n            )\n        })?;\n        archive = Some(archive_dir);\n    }\n\n    if let Err(err) = fs::rename(&next_dir, &final_dir) {\n        let mut error = anyhow!(err).context(format!(\n            \"failed to install {} into {}\",\n            skill.name,\n            final_dir.display()\n        ));\n        if let Some(archive_dir) = archive {\n            if final_dir.exists() {\n                error = error.context(format!(\n                    \"previous {} skill remains at {}\",\n                    skill.name,\n                    archive_dir.display()\n                ));\n            } else if let Err(restore_err) = fs::rename(&archive_dir, &final_dir) {\n                error = error.context(format!(\n                    \"failed to restore previous {} skill from {} to {}: {restore_err}\",\n                    skill.name,\n                    archive_dir.display(),\n                    final_dir.display()\n                ));","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/agent_command.rs#L247-L283","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nfs::rename(&next_dir, &final_dir)?;\n// after: fall back to copy when rename crosses devices\nmatch fs::rename(&next_dir, &final_dir) {\n    Ok(()) => {},\n    Err(e) if e.kind() == std::io::ErrorKind::CrossesDevices => {\n        copy_dir_all(&next_dir, &final_dir)?;\n        fs::remove_dir_all(&next_dir)?;\n    }\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"fallback","validationCode":"// pre-flight checks before install\nlet dest = &final_dir;\nassert!(dest.parent().map(|p| p.exists()).unwrap_or(false));\n// check writability\nstd::fs::OpenOptions::new().write(true).open(dest.parent().join(\".probe\")).is_ok();","typeGuard":null,"tryCatchPattern":"match fs::rename(&next_dir, &final_dir) {\n    Ok(()) => {},\n    Err(e) if e.kind() == std::io::ErrorKind::CrossesDevices => {\n        copy_dir_all(&next_dir, &final_dir)?;\n        fs::remove_dir_all(&next_dir)?;\n    }\n    Err(e) => return Err(anyhow!(e).context(format!(\"failed to install {}\", skill.name))),\n}","preventionTips":["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."],"tags":["filesystem","install","permissions"],"backgroundTag":"file-write-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}