{"record":{"id":"050f45c60679baf8","repo":"jdx/mise","slug":"source-can-only-be-used-with-one-target","errorCode":null,"errorMessage":"--source can only be used with one target","messagePattern":"--source can only be used with one target","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dotfiles/add.rs","lineNumber":100,"sourceCode":"    pub(super) yes: bool,\n}\n\nimpl DotfilesAdd {\n    /// Validate and capture the requested targets as one transactional update.\n    pub(crate) async fn run(self) -> Result<()> {\n        let mode = self.validate()?;\n        OperationScope::wrap(\"bootstrap dotfiles add\", self.dry_run, self.run_inner(mode)).await\n    }\n\n    fn validate(&self) -> Result<FileMode> {\n        if self.changed && !self.targets.is_empty() {\n            bail!(\"--changed does not accept target arguments\");\n        }\n        if !self.changed && self.targets.is_empty() {\n            bail!(\"at least one target or --changed is required\");\n        }\n        if self.source.is_some() && self.targets.len() != 1 {\n            bail!(\"--source can only be used with one target\");\n        }\n        match self.mode.as_deref() {\n            Some(\"track\") => bail!(\n                \"`--mode track` tracks a file where it is and takes no source; use `mise bootstrap dotfiles track <path>`\"\n            ),\n            Some(mode) => {\n                FileMode::parse(mode).ok_or_else(|| eyre::eyre!(\"unknown dotfile mode: {mode}\"))\n            }\n            None => Ok(system::files::default_mode()),\n        }\n    }\n\n    async fn run_inner(mut self, mode: FileMode) -> Result<()> {\n        let config = Config::get().await?;\n        let managed = system::files::files_from_config(&config)?;\n        if self.changed {\n            for req in &managed {\n                if req.mode == FileMode::Copy","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/dotfiles/add.rs#L82-L118","documentation":"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.","triggerScenarios":"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).","commonSituations":"Batch-adding several dotfiles from one directory using a single --source path, or copy-pasting a multi-file command and adding --source afterwards.","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"],"exampleFix":"// before\nmise dotfiles add --source ~/dotfiles ~/.zshrc ~/.bashrc\n// after\nmise dotfiles add --source ~/dotfiles ~/.zshrc\nmise dotfiles add --source ~/dotfiles ~/.bashrc","handlingStrategy":"validation","validationCode":"if [ -n \"$SOURCE\" ] && [ $# -ne 1 ]; then echo '--source works with exactly one target'; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","dotfiles","flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}