jdx/mise · error
failed to add
Error message
failed to add {} What it means
After `dotfiles edit` runs the DotfilesAdd flow to bring a target under management, it re-reads config and calls source_for_target to find the file's backing source path. If the add silently failed to produce a matching entry, edit bails with 'failed to add <target>'.
Solutions
- Check the file exists at the real (non-symlink) path and is readable
- Inspect [dotfiles] entries in ~/.config/mise/mise.toml after the failure to see if anything was written
- Run `mise dotfiles add <target>` explicitly and observe its output/errors
- Re-run `mise dotfiles edit <target>` after a successful add
Example fix
// before: edit with implicit add failing mise dotfiles edit ~/dotfiles/ghostty/config // after: add explicitly first, then edit mise dotfiles add ~/dotfiles/ghostty/config mise dotfiles edit ~/dotfiles/ghostty/config
Defensive patterns
Strategy: try-catch
Validate before calling
mise dotfiles add "$target" && mise config ls | grep -F "$target"
Try / catch
if let Err(e) = edit_target(t) { if e.to_string().starts_with("failed to add") { eprintln!("run `mise dotfiles add {t}` explicitly"); } } Prevention
- Run `mise dotfiles add` explicitly instead of relying on edit's implicit add
- Confirm the target is a regular readable file, not a dangling symlink
- Keep the dotfiles config directory initialized
When it happens
Trigger: The DotfilesAdd::run() completes without error but source_for_target on the refreshed Config still returns None — e.g. the add was a no-op because the file is outside the dotfiles root, already symlinked elsewhere, or matched no valid edit entry.
Common situations: Target path is a symlink whose source cannot be determined; dotfiles config directory not initialized; filesystem permission problems preventing the add; race where config reset picks up stale state.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- dotfiles: cannot enroll encrypted paths while history is…
- history is disabled (history.enabled = false)
- history is disabled (history.enabled = false)
- is not managed by [dotfiles]
- a glob is required
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/622cedfd8d8d0c60.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/dotfiles/edit.rs:102
targets: vec![self.target.clone()],
changed: false,
mode: self.mode.clone(),
source: self.source.clone(),
global: true,
local: false,
path: None,
dry_run: false,
no_apply: true,
force: false,
yes: true,
prompt_secrets: self.prompt_secrets,
}
.run()
.await?;
config = Config::reset().await?;
let Some(path) = source_for_target(&config, &target, &self.target)? else {
bail!("failed to add {}", self.target);
};
open_or_create(&path)?;
crate::cli::editor::open_in_editor(&path)?;
if self.apply {
apply_target(&self.target, self.prompt_secrets).await?;
}
Ok(())
}
}
fn source_for_target(
config: &Config,
target: &std::path::Path,
raw: &str,
) -> Result<Option<PathBuf>> {
for req in system::files::files_from_config(config)? {
if system::files::matches_target(&req.target, &req.target_raw, &[raw.to_string()]) {
return Ok(Some(req.source));View on GitHub (pinned to 533346cc37)