{"record":{"id":"aca3c6ab3cc16979","repo":"jdx/mise","slug":"at-least-one-target-or-changed-is-required","errorCode":null,"errorMessage":"at least one target or --changed is required","messagePattern":"at least one target or --changed is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dotfiles/add.rs","lineNumber":97,"sourceCode":"\n    /// Skip the confirmation prompt\n    #[usage(long, short)]\n    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)?;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/dotfiles/add.rs#L79-L115","documentation":"`mise dotfiles add` requires something to operate on: either at least one target path or the `--changed` flag. When neither is provided, `validate` (called from run before any work) bails with 'at least one target or --changed is required'.","triggerScenarios":"Running `mise dotfiles add` with no positional targets and without --changed.","commonSituations":"Invoking the bare subcommand to 'see what happens', shell scripts whose variable expansion of target paths yields an empty string, or forgetting --changed when intending to sync recently modified dotfiles.","solutions":["Pass the file(s) to add: `mise dotfiles add ~/.zshrc`","Use `mise dotfiles add --changed` to add only changed dotfiles","Check your script for empty/unexpanded target variables"],"exampleFix":"// before\nmise dotfiles add\n// after\nmise dotfiles add ~/.zshrc ~/.bashrc\n// or\nmise dotfiles add --changed","handlingStrategy":"validation","validationCode":"shift 1; [ $# -gt 0 ] || [ \"$CHANGED\" = true ] || { echo 'need targets or --changed'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass at least one target in scripts","Quote target variables so paths are not lost to expansion","Use --changed explicitly when relying on diff detection"],"tags":["cli","dotfiles","usage"],"backgroundTag":"missing-required-argument","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}