jdx/mise · error
: target must be absolute or start with ~/
Error message
{target_raw}: target must be absolute or start with ~/ What it means
Dotfile targets managed by mise must live at a fixed absolute location (or under the user's home via `~/`). run_inner resolves each target argument and, if the resulting path is still relative, bails naming the raw target, because relative targets would be ambiguous across working directories.
Solutions
- Prefix the target with `~/` (e.g. `mise dotfiles add ~/.zshrc`).
- Or pass a fully absolute path (`/home/user/.zshrc`).
- In scripts, expand the path before invoking: `mise dotfiles add "$HOME/.zshrc"`.
Example fix
// before $ mise dotfiles add .zshrc Error: .zshrc: target must be absolute or start with ~/ (mise dotfiles add) // after $ mise dotfiles add ~/.zshrc
Defensive patterns
Strategy: validation
Validate before calling
# expand to an absolute path before calling add
for t in "$@"; do
case "$t" in
/*|~/*) ;; # ok
*) echo "target '$t' must be absolute or start with ~/" >&2; exit 2 ;;
esac
done Prevention
- Always use `~/`-prefixed or absolute paths for dotfile targets.
- In scripts, expand relative paths via "$HOME/..." before invoking.
- Never rely on the current working directory to resolve dotfile targets.
When it happens
Trigger: Running `mise dotfiles add <relative-path>` (e.g. `dotfiles add .zshrc` or `dotfiles add ./config.toml`) where resolve_target_arg yields a relative PathBuf and target.is_relative() is true.
Common situations: Running the command from the directory containing the dotfile and passing a bare filename; scripts using relative paths derived from $PWD; typos like a missing leading `~` or `/`.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- `--all` needs `--to
- at least one target or --changed is required
- --changed does not accept target arguments
- is not tracked; `mise dot paths` lists what is
- `--mode track` tracks a file where it is and takes no…
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/e69fcb05ceabe140.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/dotfiles/add.rs:164
}
}
let config_path = resolve_target_config_path(ConfigPathOptions {
global: self.global || !self.local,
path: self.path.clone(),
env: None,
cwd: None,
prefer_toml: true,
prevent_home_local: true,
})?;
let mut planned = vec![];
let managed_edits = system::edits::edits_from_config(&config)?;
for target_raw in &self.targets {
let target = system::files::resolve_target_arg(target_raw)
.components()
.collect::<PathBuf>();
if target.is_relative() {
bail!("{target_raw}: target must be absolute or start with ~/");
}
if managed
.iter()
.any(|req| req.mode == FileMode::Track && req.target == target)
{
bail!(
"{target_raw}: tracked in place; pass `--mode copy` after `mise dot untrack {target_raw}` to seed a source instead"
);
}
if managed_edits.iter().any(|req| {
system::files::matches_target(
&req.path,
&req.path_raw,
std::slice::from_ref(target_raw),
)
}) {
bail!(
"{target_raw}: target is already managed by [dotfiles] edits; remove or rename those entries before adding a whole-file dotfile"View on GitHub (pinned to 533346cc37)