{"record":{"id":"ad4ef14999087411","repo":"jdx/mise","slug":"tracking-requires-a-portable-path-under-home-or-th","errorCode":null,"errorMessage":"tracking requires a portable path under home or the mise configuration directory","messagePattern":"tracking requires a portable path under home or the mise configuration directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/tracked.rs","lineNumber":827,"sourceCode":"            let actual = components.next()?;\n            if actual != expected\n                && !(cfg!(windows)\n                    && actual\n                        .as_os_str()\n                        .to_string_lossy()\n                        .eq_ignore_ascii_case(&expected.as_os_str().to_string_lossy()))\n            {\n                return None;\n            }\n        }\n        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(())","sourceCodeStart":809,"sourceCodeEnd":845,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/tracked.rs#L809-L845","documentation":"Tracked paths must live under the user's home directory or the mise configuration directory so history can store portable relative paths. ensure_portable_ancestors bails when the requested path is relative to neither base, because it cannot compute a stable relative representation.","triggerScenarios":"Calling add_requests (which runs ensure_portable_ancestors) with an absolute path that is not under `home` or `global_config_dir()`, so `relative(base)` returns None for every candidate base.","commonSituations":"Tracking a file in /etc, /opt, another user's home, or a directory outside $HOME on purpose; CI paths in temporary directories; typos producing paths outside home.","solutions":["Move the file into your home directory or the mise config directory and track it there.","Use a symlink inside home pointing to the real file and track the link explicitly (not through it).","If the file genuinely must live outside home, manage it outside mise history tracking."],"exampleFix":"// before\nmise history track /etc/myapp/config.toml\n// after\ncp /etc/myapp/config.toml ~/.config/myapp/config.toml\nmise history track ~/.config/myapp/config.toml","handlingStrategy":"validation","validationCode":"fn is_portable(p: &Path, home: &Path, config: &Path) -> bool {\n  p.starts_with(home) || p.starts_with(config)\n}","typeGuard":null,"tryCatchPattern":"match add_requests(reqs) {\n  Err(e) if e.to_string().contains(\"portable path\") => move_under_home_and_retrack(),\n  other => other?,\n}","preventionTips":["Keep all dotfiles you track under $HOME or the mise config dir.","Never track /etc, /opt, or temp directories with history.","Resolve absolute paths before adding to catch paths outside the roots."],"tags":["path","tracking","validation"],"backgroundTag":"path-traversal-blocked","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"}