jdx/mise · error
--source can only be used with one target
Error message
--source can only be used with one target
What it means
When `--source` is given to `mise dotfiles add`, the command tracks a single target file and links it from the specified source; with multiple targets the source mapping would be ambiguous. `validate` therefore bails with '--source can only be used with one target' when source.is_some() && targets.len() != 1.
Source
Thrown at src/cli/dotfiles/add.rs:100
pub(super) yes: bool,
}
impl DotfilesAdd {
/// Validate and capture the requested targets as one transactional update.
pub(crate) async fn run(self) -> Result<()> {
let mode = self.validate()?;
OperationScope::wrap("bootstrap dotfiles add", self.dry_run, self.run_inner(mode)).await
}
fn validate(&self) -> Result<FileMode> {
if self.changed && !self.targets.is_empty() {
bail!("--changed does not accept target arguments");
}
if !self.changed && self.targets.is_empty() {
bail!("at least one target or --changed is required");
}
if self.source.is_some() && self.targets.len() != 1 {
bail!("--source can only be used with one target");
}
match self.mode.as_deref() {
Some("track") => bail!(
"`--mode track` tracks a file where it is and takes no source; use `mise bootstrap dotfiles track <path>`"
),
Some(mode) => {
FileMode::parse(mode).ok_or_else(|| eyre::eyre!("unknown dotfile mode: {mode}"))
}
None => Ok(system::files::default_mode()),
}
}
async fn run_inner(mut self, mode: FileMode) -> Result<()> {
let config = Config::get().await?;
let managed = system::files::files_from_config(&config)?;
if self.changed {
for req in &managed {
if req.mode == FileMode::CopyView on GitHub (pinned to afd2eddd3a)
Solutions
- Run one `mise dotfiles add --source <src> <target>` per file
- If several files share a source directory, loop over the targets in your script
- Omit --source and use default tracking when adding multiple targets
Example fix
// before mise dotfiles add --source ~/dotfiles ~/.zshrc ~/.bashrc // after mise dotfiles add --source ~/dotfiles ~/.zshrc mise dotfiles add --source ~/dotfiles ~/.bashrc
Defensive patterns
Strategy: validation
Validate before calling
if [ -n "$SOURCE" ] && [ $# -ne 1 ]; then echo '--source works with exactly one target'; exit 1; fi
Prevention
- Use --source only in single-file invocations
- Loop over targets, invoking mise once per file when --source is needed
- Keep multi-target adds on the default tracking mode
When it happens
Trigger: Running `mise dotfiles add --source <src> <target1> <target2>` — i.e. --source combined with more than one positional target (including zero targets, which would hit this check only if source is set with no targets).
Common situations: Batch-adding several dotfiles from one directory using a single --source path, or copy-pasting a multi-file command and adding --source afterwards.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- --changed does not accept target arguments
- --operation takes at most one checkpoint reference
- locked mode requires lockfile to be enabled hint: Remove `lo
- at least one target or --changed is required
- `--mode track` tracks a file where it is and takes no source
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/050f45c60679baf8.
Report an issue: GitHub.