jdx/mise · error

local saved history changed since planning; nothing was…

Error message

local saved history changed since planning; nothing was applied; run pull again

What it means

validate_starting_head compares the recorded starting_head of the active recovery operation with the head the caller planned against. If local saved history changed since the pull was planned, the expectation mismatches and nothing is applied, forcing a fresh pull.

Solutions

  1. Run pull again to recompute the plan against the current head, then apply immediately
  2. Ensure no other mise operations run between plan and apply (single process, operation lock held)
  3. Commit or settle local history changes before pulling

Example fix

// before: stale plan
apply(planned_pull);
// after: fresh pull-then-apply
let pull = history.pull()?;
history.apply(pull)?; // same locked session
Defensive patterns

Strategy: retry

Validate before calling

if history.current_head() != planned_head {
    eprintln!("head moved; re-pull before applying");
}

Try / catch

match scope.validate_starting_head(expected) {
    Err(e) if e.to_string().contains("run pull again") => {
        let fresh = history.pull()?;
        scope.validate_starting_head(fresh.starting_head())?;
        history.apply(fresh)?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling validate_starting_head(expected) when writer.starting_head differs — e.g. new checkpoints/commits were written locally after the pull plan was computed, or a concurrent history operation advanced the head between plan and apply.

Common situations: Planning a pull, then running commands (or another mise instance) that write history before applying; two machines or processes racing on the same MISE_STATE_DIR; stale plan applied much later.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/39276f27256eacdd. Report an issue: GitHub.

Appendix: source

Thrown at src/system/history/scope.rs:254

                warn!("history: could not persist the capture label: {err:#}");
            }
        }
    }

    /// The protective checkpoint this operation took, if any.
    pub(crate) fn before(&self) -> Option<(u64, String)> {
        self.0
            .as_ref()
            .and_then(|shared| lock_unpoisoned(shared).before.clone())
    }

    pub(crate) fn validate_starting_head(&self, expected: Option<&str>) -> Result<()> {
        let Some(shared) = &self.0 else {
            eyre::bail!("incoming application requires an active recovery operation");
        };
        let writer = lock_unpoisoned(shared);
        if writer.starting_head.as_deref() != expected {
            eyre::bail!(
                "local saved history changed since planning; nothing was applied; run pull again"
            );
        }
        Ok(())
    }

    /// Retakes the protective checkpoint, replacing the earlier one, when
    /// files changed between it and the verified plan.
    pub(crate) fn recapture_before(&self, paths: &[PathBuf]) -> Result<()> {
        let Some(shared) = &self.0 else {
            return Ok(());
        };
        let mut writer = lock_unpoisoned(shared);
        // held across the reservation, the capture, and the removal: the
        // capture writes the index and a checkpoint ref, which a concurrent
        // `mise dot save` must not interleave with
        let _store_lock = writer.store.lock()?;
        let previous = writer.before.take();

View on GitHub (pinned to 533346cc37)