{"record":{"id":"3c911987393c499a","repo":"jdx/mise","slug":"choose-explicit-paths-or-all-not-both","errorCode":null,"errorMessage":"choose explicit paths or `--all`, not both","messagePattern":"choose explicit paths or `--all`, not both","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/replay.rs","lineNumber":112,"sourceCode":"    from: String,\n    to: String,\n    /// The permission bits the checkpoint recorded for the file (only\n    /// modes git cannot express, `0600` say), and for the directories\n    /// above it.\n    bits: Option<u32>,\n    dir_bits: Vec<(PathBuf, u32)>,\n}\n\n/// One checkpoint and the paths to take from it.\nstruct Target {\n    entry: Entry,\n    paths: Vec<PathBuf>,\n}\n\npub(crate) async fn rollback(req: RollbackRequest) -> Result<()> {\n    ensure_enabled()?;\n    if req.all && !req.paths.is_empty() {\n        bail!(\"choose explicit paths or `--all`, not both\");\n    }\n    if req.paths.is_empty() && !(req.to.is_some() && req.all) {\n        bail!(\n            \"name the paths to roll back, or `--to <ref> --all` for everything the checkpoint covers\"\n        );\n    }\n    if req.to.is_none() && req.all {\n        bail!(\"`--all` needs `--to <ref>`\");\n    }\n    let (store, tracked, entries) = crate::cli::dotfiles::history::open().await?;\n    let repo = store\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"rolling back requires git\"))?;\n    let live = live_tree(repo, &tracked)?;\n    let paths: Vec<PathBuf> = req\n        .paths\n        .iter()\n        .map(|path| normalize_target(path))","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/replay.rs#L94-L130","documentation":"The history rollback request accepts either explicit paths or the `--all` flag, but not both: `--all` means 'everything the checkpoint covers', which is contradictory with an explicit path list. rollback rejects the request up front with this message before doing any work.","triggerScenarios":"Calling rollback with a RollbackRequest where all == true AND paths is non-empty — e.g. `mise history rollback --all path1 path2` or programmatically setting both fields.","commonSituations":"Users adding `--all` for safety while also listing paths out of habit; scripts templating flags and appending a path list; shell aliases that hard-code `--all`.","solutions":["Drop `--all` when you want to roll back specific paths: `rollback path1 path2`","Drop the path list when you want everything: `rollback --to <ref> --all`","Fix the calling script/alias so it emits either paths or `--all`, never both"],"exampleFix":"// before\nrollback(RollbackRequest { all: true, paths: vec![\"/a\".into()], .. })\n// after\nrollback(RollbackRequest { all: false, paths: vec![\"/a\".into()], .. })\n// or: rollback(RollbackRequest { all: true, paths: vec![], to: Some(ref), .. })","handlingStrategy":"validation","validationCode":"fn valid_rollback_req(req: &RollbackRequest) -> bool {\n    !(req.all && !req.paths.is_empty())\n        && (!req.paths.is_empty() || (req.to.is_some() && req.all))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose one mode per invocation: named paths XOR --all","In scripts, branch on intent rather than appending both flags","Add a shell alias per mode (e.g. rollback-paths, rollback-all) to prevent flag mixing"],"tags":["cli","arguments","rollback"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}