{"record":{"id":"e86fb10cebaa444f","repo":"jdx/mise","slug":"ambiguous-variants-for","errorCode":null,"errorMessage":"ambiguous variants for {}","messagePattern":"ambiguous variants for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/manifest.rs","lineNumber":253,"sourceCode":"\n    /// Restore enrollment from Git without needing a captured mise config.\n    /// Deployment inputs are validated separately; none are inferred here.\n    pub(crate) fn tracking(&self) -> Result<super::tracked::TrackedSet> {\n        self.validate()?;\n        let roots = super::sync::layout::Roots::current();\n        let environments = super::select::active_environments();\n        let mut tracked = super::tracked::TrackedSet {\n            manifest: self.clone(),\n            exclude: self.exclude.clone(),\n            ..Default::default()\n        };\n        for enrollment in &self.enrollment {\n            let variant = match super::select::select(&enrollment.variants, &environments) {\n                super::select::Selection::Single => None,\n                super::select::Selection::Variant(variant) => Some(variant.name()),\n                super::select::Selection::NoMatch => continue,\n                super::select::Selection::Ambiguous(_) => {\n                    bail!(\"ambiguous variants for {}\", enrollment.path)\n                }\n            };\n            let local = roots\n                .locate(&enrollment.path)\n                .path()\n                .ok_or_else(|| eyre::eyre!(\"invalid enrollment path {}\", enrollment.path))?\n                .to_path_buf();\n            super::tracked::ensure_portable_ancestors(&local)?;\n            let mut policy =\n                crate::system::files::FilePolicy::for_mode(crate::system::files::FileMode::Track);\n            policy.autosave = enrollment.autosave;\n            policy.encrypt = enrollment.encrypt;\n            let mut entry = super::tracked::TrackedEntry::new(local, \"track\", policy);\n            entry.variant = variant;\n            tracked.entries.push(entry);\n        }\n        Ok(tracked)\n    }","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/manifest.rs#L235-L271","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Adjust variant conditions in the manifest so exactly one matches the current environment set.","Add a distinguishing predicate (hostname, tag) to one of the overlapping variants.","Track with a narrower environment set that selects a single variant.","Remove the redundant variant if it duplicates another."],"exampleFix":"// before (two variants both match)\n[[variant]]\nmatch.os = \"linux\"\n[[variant]]\nmatch.hostname = \"work\"\n// after\n[[variant]]\nmatch.os = \"linux\"\nmatch.hostname = \"work\"","handlingStrategy":"validation","validationCode":"// verify exactly one variant matches before tracking:\n// check variant predicates (os/hostname/tags) against the current environment","typeGuard":null,"tryCatchPattern":"// on \"ambiguous variants for {path}\": fix the manifest's variant\n// conditions for that path, then retry the tracking operation","preventionTips":["Design variant predicates to be mutually exclusive.","Test variant selection after every manifest edit.","Avoid duplicating match conditions across variants."],"tags":["variants","ambiguity","manifest","selection"],"backgroundTag":"ambiguous-variant-selection","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}