{"record":{"id":"74c1c19e221afa70","repo":"GitoxideLabs/gitoxide","slug":"input-paths-need-to-be-relative-but-path-is-n","errorCode":null,"errorMessage":"Input paths need to be relative, but {path:?} is not.","messagePattern":"Input paths need to be relative, but (.+?) is not\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gitoxide-core/src/repository/index/mod.rs","lineNumber":56,"sourceCode":"\n    Ok(())\n}\n\npub fn from_list(\n    entries_file: PathBuf,\n    index_path: Option<PathBuf>,\n    force: bool,\n    skip_hash: bool,\n) -> anyhow::Result<()> {\n    use std::io::BufRead;\n    let object_hash = gix::hash::Kind::Sha1;\n\n    let mut index = gix::index::State::new(object_hash);\n    for path in std::io::BufReader::new(std::fs::File::open(entries_file)?).lines() {\n        let path: PathBuf = path?.into();\n        #[expect(clippy::unnecessary_debug_formatting)]\n        if !path.is_relative() {\n            bail!(\"Input paths need to be relative, but {path:?} is not.\")\n        }\n        let path = gix::path::into_bstr(path);\n        index.dangerously_push_entry(\n            gix::index::entry::Stat::default(),\n            gix::hash::ObjectId::empty_blob(object_hash),\n            gix::index::entry::Flags::empty(),\n            gix::index::entry::Mode::FILE,\n            gix::path::to_unix_separators_on_windows(path).as_ref(),\n        );\n    }\n    index.sort_entries();\n\n    let options = gix::index::write::Options {\n        skip_hash,\n        ..Default::default()\n    };\n    match index_path {\n        Some(index_path) => {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/repository/index/mod.rs#L38-L74","documentation":"When constructing an index from a list of paths (entries file, one path per line), every input path must be relative to the repository root. Absolute paths are rejected with this error because index entries are stored as relative paths by design and writing an absolute path would corrupt the index semantics.","triggerScenarios":"Calling `from_list` in gitoxide-core/src/repository/index/mod.rs (CLI `gix index from-list`) where the entries file contains an absolute path like `/home/user/repo/src/main.rs` or a path with a drive/leading separator.","commonSituations":"Generating the entries list with a tool that emits absolute paths (e.g. `find $(pwd)`); piping `git ls-files` output through a script that prefixes the workdir; copy-pasting full paths from an IDE.","solutions":["Make the path relative in the entries file (strip the repository root prefix)","Generate the list with a relative-path command (e.g. `git ls-files` or `find .`)","Pre-process the entries file to remove leading `/` or absolute prefixes before passing it"],"exampleFix":"// before (entries file)\n/home/user/repo/src/main.rs\n// after (entries file)\nsrc/main.rs","handlingStrategy":"validation","validationCode":"use std::path::{Path, PathBuf};\nfn sanitize_entry(path: &str, root: &Path) -> PathBuf {\n    let p = Path::new(path);\n    p.strip_prefix(root).unwrap_or(p).to_path_buf()\n}\n// apply to every line read from the entries file","typeGuard":"fn is_relative_entry(p: &Path) -> bool { p.is_relative() }","tryCatchPattern":"match index::from_list(repo, &entries_file, object_hash) {\n    Err(e) if e.to_string().contains(\"need to be relative\") => {\n        eprintln!(\"entries file contains absolute paths; strip the repo root prefix\");\n    }\n    other => other?,\n}","preventionTips":["Generate entries with relative-path commands (git ls-files, find .)","Strip the repository root prefix from paths before writing the list","Validate every line with Path::is_relative() before invoking","Avoid tools that emit absolute paths by default (e.g. find $(pwd))"],"tags":["cli","index","path-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}