jdx/mise · error
--source can only be used with one target
Error message
--source can only be used with one target
What it means
The `--source` flag for `mise dotfiles add` specifies where to link a target from, and only makes sense for exactly one target. validate() bails when `--source` is given together with zero or multiple targets, since the single source cannot be applied unambiguously to several targets.
Solutions
- Run one `mise dotfiles add --source <path> <single-target>` per file.
- If linking multiple files from a directory, add each target separately with its own --source.
- Omit --source if you intended to track files in place (track mode infers no source).
Example fix
// before $ mise dotfiles add --source ~/dotfiles/zshrc ~/.zshrc ~/.bashrc // after $ mise dotfiles add --source ~/dotfiles/zshrc ~/.zshrc $ mise dotfiles add --source ~/dotfiles/bashrc ~/.bashrc
Defensive patterns
Strategy: validation
Validate before calling
# guard: --source requires exactly one target if [ -n "$SOURCE" ] && [ $# -ne 1 ]; then echo "--source works with exactly one target" >&2; exit 2 fi
Prevention
- Loop over targets in scripts, calling add with --source once per file.
- Treat --source as a single-target option.
- Omit --source for in-place tracking use cases.
When it happens
Trigger: Running `mise dotfiles add --source <path> <t1> <t2>` (multiple targets) or `mise dotfiles add --source <path> --changed` (no targets) — source.is_some() && targets.len() != 1 in validate().
Common situations: Trying to batch-link several dotfiles from one source path in a single command; scripting a loop that accumulates multiple targets while keeping a single --source flag.
Related errors
- --changed does not accept target arguments
- `--mode track` tracks a file where it is and takes no…
- a repository preview directory requires a dry run
- `--all` needs `--to
- at least one target or --changed is required
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/050f45c60679baf8.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/dotfiles/add.rs:104
pub(super) prompt_secrets: 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 dot 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 secrets = system::secrets::resolve(&config, self.prompt_secrets)?;
let managed = system::files::files_from_config(&config)?;
if self.changed {
for req in &managed {View on GitHub (pinned to 533346cc37)