{"record":{"id":"c7e53d678a0d5c2c","repo":"jdx/mise","slug":"brew-cask-kind-name-is-ambiguous","errorCode":null,"errorMessage":"brew-cask: {kind} '{name}' is ambiguous: {}","messagePattern":"brew-cask: (.+?) '(.+?)' is ambiguous: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/mod.rs","lineNumber":3037,"sourceCode":"            continue;\n        }\n        let path = target.join(&suffix);\n        if path.is_file() {\n            matches.push(path);\n        }\n    }\n    matches.sort();\n    matches.dedup();\n    single_match(&matches, \"APPDIR artifact\", source)\n}\n\n/// `kind` and `name` build the ambiguity error, e.g. \"brew-cask: APPDIR\n/// artifact 'x' is ambiguous: a, b\".\nfn single_match(matches: &[PathBuf], kind: &str, name: &str) -> Result<Option<PathBuf>> {\n    match matches {\n        [] => Ok(None),\n        [path] => Ok(Some(path.clone())),\n        _ => bail!(\n            \"brew-cask: {kind} '{name}' is ambiguous: {}\",\n            matches\n                .iter()\n                .map(|path| path.display().to_string())\n                .collect::<Vec<_>>()\n                .join(\", \")\n        ),\n    }\n}\n\nfn find_generated_completion_file(root: &Path, executable: &str) -> Result<Option<PathBuf>> {\n    let executable_path = Path::new(executable);\n    let direct = root.join(executable_path);\n    if direct.is_file() {\n        return Ok(Some(direct));\n    }\n    let matches = find_file_artifacts(root, executable_path);\n    single_match(&matches, \"completion executable\", executable)","sourceCodeStart":3019,"sourceCodeEnd":3055,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/cask/mod.rs#L3019-L3055","documentation":"When resolving a cask artifact by name (e.g. an APPDIR artifact), single_match expects zero or exactly one match among candidate paths. If multiple paths match the requested kind/name, the selection is ambiguous, so it bails listing all matching paths. The doc comment shows the produced message, e.g. \"brew-cask: APPDIR artifact 'x' is ambiguous: a, b\".","triggerScenarios":"Calling single_match (via the artifact resolution used by cask install/linking) with a kind/name that matches two or more staged paths in the `matches` slice — e.g. a glob or name pattern that hits several files/directories in the staged cask.","commonSituations":"A cask stages multiple artifacts whose names collide or both match the requested target (e.g. duplicate app bundles, case differences, an app plus a similarly named directory); a cask definition's artifact name is too generic after an upstream cask update added another matching entry.","solutions":["Use a more specific artifact name in the cask definition so exactly one staged path matches.","Inspect the listed matching paths and remove/rename the duplicate in the staged caskroom.","Update the cask definition to reflect the upstream artifact layout after a cask version change.","If the ambiguity comes from stale staging, uninstall and reinstall the cask to rebuild a clean caskroom."],"exampleFix":"// before (ambiguous artifact name)\n[[artifacts.appdir]]\nname = \"MyApp\"\n\n// after (unique name)\n[[artifacts.appdir]]\nname = \"MyApp.app\"","handlingStrategy":"validation","validationCode":"use std::path::PathBuf;\nfn unambiguous(matches: &[PathBuf]) -> bool {\n    matches.len() <= 1\n}\n// only proceed to single_match when this returns true; otherwise narrow the name","typeGuard":null,"tryCatchPattern":"// Rust\nmatch resolve_cask_artifact(&cask, kind, name) {\n    Err(e) if e.to_string().contains(\"is ambiguous\") => {\n        // parse listed paths from the message or re-glob with a stricter name\n    }\n    other => other,\n}","preventionTips":["Use fully qualified artifact names (e.g. 'MyApp.app' not 'MyApp') in cask definitions.","After upstream cask updates, verify the artifact list for new colliding entries.","Keep the caskroom clean: reinstall rather than mixing versions in one directory.","Test artifact resolution with glob patterns that could match multiple paths."],"tags":["brew-cask","ambiguity","artifact-resolution","invalid-argument-value"],"backgroundTag":"invalid-argument-value","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"}