jdx/mise · error

ambiguous variants for {}

Error message

ambiguous variants for {}

What it means

Thrown by `tracking` in manifest.rs when `select::select` returns `Selection::Ambiguous` for an enrollment's variants: the active environments match more than one variant, so no single variant name can be recorded for that enrollment path. Tracking requires an unambiguous variant selection to write correct history.

Source

Thrown at src/system/history/manifest.rs:253

    /// Restore enrollment from Git without needing a captured mise config.
    /// Deployment inputs are validated separately; none are inferred here.
    pub(crate) fn tracking(&self) -> Result<super::tracked::TrackedSet> {
        self.validate()?;
        let roots = super::sync::layout::Roots::current();
        let environments = super::select::active_environments();
        let mut tracked = super::tracked::TrackedSet {
            manifest: self.clone(),
            exclude: self.exclude.clone(),
            ..Default::default()
        };
        for enrollment in &self.enrollment {
            let variant = match super::select::select(&enrollment.variants, &environments) {
                super::select::Selection::Single => None,
                super::select::Selection::Variant(variant) => Some(variant.name()),
                super::select::Selection::NoMatch => continue,
                super::select::Selection::Ambiguous(_) => {
                    bail!("ambiguous variants for {}", enrollment.path)
                }
            };
            let local = roots
                .locate(&enrollment.path)
                .path()
                .ok_or_else(|| eyre::eyre!("invalid enrollment path {}", enrollment.path))?
                .to_path_buf();
            super::tracked::ensure_portable_ancestors(&local)?;
            let mut policy =
                crate::system::files::FilePolicy::for_mode(crate::system::files::FileMode::Track);
            policy.autosave = enrollment.autosave;
            policy.encrypt = enrollment.encrypt;
            let mut entry = super::tracked::TrackedEntry::new(local, "track", policy);
            entry.variant = variant;
            tracked.entries.push(entry);
        }
        Ok(tracked)
    }

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Adjust variant conditions in the manifest so exactly one matches the current environment set.
  2. Add a distinguishing predicate (hostname, tag) to one of the overlapping variants.
  3. Track with a narrower environment set that selects a single variant.
  4. Remove the redundant variant if it duplicates another.

Example fix

// before (two variants both match)
[[variant]]
match.os = "linux"
[[variant]]
match.hostname = "work"
// after
[[variant]]
match.os = "linux"
match.hostname = "work"
Defensive patterns

Strategy: validation

Validate before calling

// verify exactly one variant matches before tracking:
// check variant predicates (os/hostname/tags) against the current environment

Try / catch

// on "ambiguous variants for {path}": fix the manifest's variant
// conditions for that path, then retry the tracking operation

Prevention

When it happens

Trigger: Calling tracking with an environments set that satisfies two or more overlapping variant predicates on one enrolled path (e.g. variants keyed on overlapping hostnames, OS values, or environment tags).

Common situations: Defining two variants whose conditions both match the current machine (e.g. `os=linux` and `hostname=work` both applying); duplicating a variant condition when editing the manifest by hand.

Related errors


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