{"record":{"id":"b5fbb2e70b3dab11","repo":"jdx/mise","slug":"cannot-track-through-symlinked-parent-expli","errorCode":null,"errorMessage":"cannot track {} through symlinked parent {}; explicitly track the link itself and its real target instead","messagePattern":"cannot track (.+?) through symlinked parent (.+?); explicitly track the link itself and its real target instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/tracked.rs","lineNumber":838,"sourceCode":"        Some(components.collect::<PathBuf>())\n    };\n    let Some((base, rest)) = bases\n        .iter()\n        .filter_map(|base| relative(base).map(|rest| (base, rest)))\n        .max_by_key(|(base, _)| base.components().count())\n    else {\n        eyre::bail!(\n            \"tracking requires a portable path under home or the mise configuration directory\"\n        );\n    };\n    let mut ancestor = base.clone();\n    for component in rest\n        .components()\n        .take(rest.components().count().saturating_sub(1))\n    {\n        ancestor.push(component);\n        if file::is_symlink_or_junction(&ancestor) {\n            eyre::bail!(\n                \"cannot track {} through symlinked parent {}; explicitly track the link itself and its real target instead\",\n                display_path(path),\n                display_path(&ancestor)\n            );\n        }\n    }\n    Ok(())\n}\n\n/// Turns a display or absolute path into its snapshot-tree path.\npub(crate) fn display_to_tree_path(path: &str) -> String {\n    // the link itself, never its destination: a tracked symlink is captured\n    // as a link and addressed as one\n    let expanded = normalize_target(Path::new(path));\n    let config = normalize(&global_config_dir());\n    if let Ok(relative) = expanded.strip_prefix(config) {\n        return format!(\"config/{}\", relative.to_string_lossy().replace('\\\\', \"/\"))\n            .trim_end_matches('/')","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/tracked.rs#L820-L856","documentation":"Tracking a path through a symlinked parent would make history store an unstable, machine-specific path and could change the link's target bytes on restore. ensure_portable_ancestors walks each ancestor component and bails if any intermediate component is a symlink or junction, telling you to track the link and its target explicitly instead.","triggerScenarios":"add_requests -> ensure_portable_ancestors with a path like ~/links/dotfiles/settings.json where `~/links/dotfiles` is a symlink; file::is_symlink_or_junction succeeds on an ancestor component.","commonSituations":"Dotfiles managed via a symlinked repo folder (e.g. ~/dotfiles symlinked into ~/.config); macOS setups linking ~/Library subpaths; junctions on Windows.","solutions":["Track the symlink itself and its real target as separate explicit entries instead of paths beneath it.","Track the real (resolved) path directly under home/config without traversing the link.","Replace the intermediate symlink with a real directory if the layout allows."],"exampleFix":"// before\nmise history track ~/dotfiles/vimrc   # ~/dotfiles is a symlink\n// after\nmise history track ~/dotfiles          # track the link itself\nmise history track ~/real/dotfiles/vimrc  # and/or the real target","handlingStrategy":"validation","validationCode":"fn passes_symlink(p: &Path) -> std::io::Result<bool> {\n  let mut cur = p.to_path_buf();\n  while let Some(parent) = cur.parent() {\n    if std::fs::symlink_metadata(&parent)?.file_type().is_symlink() { return Ok(false); }\n    cur = parent.to_path_buf();\n  }\n  Ok(true)\n}","typeGuard":null,"tryCatchPattern":"match add_requests(reqs) {\n  Err(e) if e.to_string().contains(\"symlinked parent\") => track_link_and_target_instead(),\n  other => other?,\n}","preventionTips":["Track symlinked dotfile repos as the link + target, not paths beneath the link.","Prefer real directories over intermediate symlinks in ~/.config.","Check ancestors with `namei -l <path>` before tracking."],"tags":["symlink","path","tracking"],"backgroundTag":"unsupported-operation","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"}