jdx/mise · error

`--all` needs `--to <ref>`

Error message

`--all` needs `--to <ref>`

What it means

The --all flag is only meaningful together with --to <ref>: it means "restore everything the checkpoint at <ref> covers". Requesting --all without --to leaves no reference to restore from, so mise rejects it. This check runs after the paths/`--all` mutual-exclusion check in rollback.

Source

Thrown at src/system/history/replay.rs:120

/// One checkpoint and the paths to take from it.
struct Target {
    entry: Entry,
    paths: Vec<PathBuf>,
}

pub(crate) async fn rollback(req: RollbackRequest) -> Result<()> {
    ensure_enabled()?;
    if req.all && !req.paths.is_empty() {
        bail!("choose explicit paths or `--all`, not both");
    }
    if req.paths.is_empty() && !(req.to.is_some() && req.all) {
        bail!(
            "name the paths to roll back, or `--to <ref> --all` for everything the checkpoint covers"
        );
    }
    if req.to.is_none() && req.all {
        bail!("`--all` needs `--to <ref>`");
    }
    let (store, tracked, entries) = crate::cli::dotfiles::history::open().await?;
    let repo = store
        .repo()
        .ok_or_else(|| eyre::eyre!("rolling back requires git"))?;
    let live = live_tree(repo, &tracked)?;
    let paths: Vec<PathBuf> = req
        .paths
        .iter()
        .map(|path| normalize_target(path))
        .collect();
    for path in &paths {
        if tracked.entry_for(path).is_none() {
            bail!(
                "{} is not tracked; `mise bootstrap dotfiles paths` lists what is",
                display_path(path)
            );
        }

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Add a ref: `mise bootstrap dotfiles rollback --to <ref> --all`
  2. Find a ref via `mise bootstrap dotfiles history`
  3. If you only want certain files, name them explicitly instead of using --all

Example fix

// before
mise bootstrap dotfiles rollback --all
// after
mise bootstrap dotfiles rollback --to HEAD~1 --all
Defensive patterns

Strategy: validation

Validate before calling

if (req.all && !req.to) {
  throw new Error("--all requires --to <ref>");
}

Type guard

const allHasRef = (req: { all?: boolean; to?: string }) =>
  req.all !== true || typeof req.to === "string";

Try / catch

try {
  await rollback(req);
} catch (e) {
  if (String(e).includes("--all` needs")) {
    req.to = resolveLatestRef();
    await rollback(req);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `rollback --all` without `--to <ref>` (req.to.is_none() && req.all). Typically after fixing the not-both error by dropping paths but keeping --all.

Common situations: Users assume --all means "all history" or "latest checkpoint"; incremental edits to a command strip the --to argument while leaving --all in place.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/fb8375613b479222. Report an issue: GitHub.