{"record":{"id":"d3a3637b1f185292","repo":"jdx/mise","slug":"source-pattern-did-not-match-path","errorCode":null,"errorMessage":"source pattern did not match {path}","messagePattern":"source pattern did not match (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":1365,"sourceCode":"                policy,\n                variants: vec![],\n                enabled,\n            })\n        })\n        .collect()\n}\n\nfn is_glob_pattern(path: &Path) -> bool {\n    path.to_string_lossy()\n        .chars()\n        .any(|c| matches!(c, '*' | '?' | '['))\n}\n\nfn wildcard_captures(pattern: &str, path: &Path) -> Result<Vec<String>> {\n    let path = normalize_path_separators(&path.to_string_lossy());\n    let re = wildcard_regex(pattern)?;\n    let Some(captures) = re.captures(&path) else {\n        bail!(\"source pattern did not match {path}\");\n    };\n    Ok((1..captures.len())\n        .map(|i| {\n            captures\n                .get(i)\n                .map(|m| m.as_str().to_string())\n                .unwrap_or_default()\n        })\n        .collect())\n}\n\nfn wildcard_regex(pattern: &str) -> Result<Regex> {\n    let mut re = String::from(\"^\");\n    let pattern = normalize_path_separators(pattern);\n    let mut chars = pattern.chars().peekable();\n    while let Some(ch) = chars.next() {\n        match ch {\n            '*' if chars.peek() == Some(&'*') => {","sourceCodeStart":1347,"sourceCodeEnd":1383,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L1347-L1383","documentation":"wildcard_captures compiles a dotfile source pattern (with wildcards) into a regex and matches a concrete path against it. If the path does not match the pattern — e.g. after a wildcard expansion where the enumerated path diverges from the pattern — it bails with this message instead of producing captures.","triggerScenarios":"Expanding a wildcard dotfile source (e.g. pattern `dotfiles/config/*.conf`) where an enumerated candidate path fails to re-match the pattern, typically due to path separator normalization differences or a path discovered outside the pattern's scope.","commonSituations":"Symlinks or `..` segments producing a path that no longer matches the glob; mixing `\\` and `/` on Windows; a source directory that changed between globbing and capture (race or stale cache).","solutions":["Check that the source pattern's wildcards actually cover the reported path.","Normalize the path (remove symlinks/`..`) or adjust the pattern to the real directory layout.","Re-run the dotfiles apply so globbing and matching happen against a consistent tree."],"exampleFix":"// before\n\"~/.config/app/*\" = { source = \"dotfiles/app/*.yml\" }  // files are actually .yaml\n// after\n\"~/.config/app/*\" = { source = \"dotfiles/app/*.yaml\" }","handlingStrategy":"try-catch","validationCode":"// Pre-check the pattern against real paths before apply:\nfor path in candidate_paths {\n    assert!(wildcard_regex(pattern).unwrap().is_match(&normalize(path)),\n            \"pattern {pattern} does not cover {path}\");\n}","typeGuard":null,"tryCatchPattern":"match dotfiles_apply() {\n    Err(e) if e.to_string().contains(\"source pattern did not match\") => {\n        // inspect pattern vs path and fix the glob\n    }\n    other => other?,\n}","preventionTips":["Avoid symlinks and .. inside wildcarded source trees.","Keep glob patterns and directory extensions in sync (.conf vs .yaml).","Test wildcard entries with `mise dotfiles status` before apply."],"tags":["dotfiles","glob","wildcard","mise"],"backgroundTag":"path-did-not-match-pattern","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"}