{"record":{"id":"fe33fc9385b0a718","repo":"pkgxdev/pkgx","slug":"could-not-get-the-base-name-of-the-installation-pa","errorCode":null,"errorMessage":"Could not get the base name of the installation path","messagePattern":"Could not get the base name of the installation path","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/lib/src/install.rs","lineNumber":229,"sourceCode":"async fn make_symlink(\n    shelf: &Path,\n    symname: &str,\n    installation: &Installation,\n) -> Result<(), Box<dyn Error>> {\n    let symlink_path = shelf.join(symname);\n\n    if symlink_path.is_symlink() {\n        if let Err(err) = fs::remove_file(&symlink_path) {\n            if err.kind() != std::io::ErrorKind::NotFound {\n                return Err(err.into());\n            }\n        }\n    }\n\n    let target = installation\n        .path\n        .file_name()\n        .ok_or_else(|| anyhow::anyhow!(\"Could not get the base name of the installation path\"))?;\n\n    #[cfg(not(windows))]\n    std::os::unix::fs::symlink(target, &symlink_path)?;\n    #[cfg(windows)]\n    std::os::windows::fs::symlink_dir(target, symlink_path)?;\n\n    Ok(())\n}\n","sourceCodeStart":211,"sourceCodeEnd":238,"githubUrl":"https://github.com/pkgxdev/pkgx/blob/6de1d7e953b98061f69db95d4bd45a2a6ee5d7da/crates/lib/src/install.rs#L211-L238","documentation":"`make_symlink` needs the final path component of the installation directory to create the cellar symlink target. If `installation.path.file_name()` returns `None` — the path is empty, `/`, `..`, or otherwise has no basename — it raises `Could not get the base name of the installation path`. Without a basename no valid symlink target can be constructed.","triggerScenarios":"Calling `install()`/`symlink` where `installation.path` resolves to the filesystem root, is empty, ends in `..`, or was constructed incorrectly (e.g. cellar path config pointing at `/` or an empty PKGX_DIR-derived path).","commonSituations":"Setting PKGX_DIR (or the cellar path) to `/` or a malformed value, a config bug producing an empty path, or programmatically constructing an `Installation` with a root/empty path in tests or scripts.","solutions":["Inspect the resolved cellar path (echo $PKGX_DIR, check Config) and ensure it points at a real subdirectory, not `/` or an empty string","Unset/correct a bogus PKGX_DIR environment variable so the default ~/.pkgx cellar is used","When constructing installations programmatically, pass a path with an actual final component (use `PathBuf::from(\"...\").join(name)`)"],"exampleFix":"// before\nexport PKGX_DIR=/\n// after\nexport PKGX_DIR=$HOME/.pkgx","handlingStrategy":"validation","validationCode":"fn cellar_path_valid(p: &std::path::Path) -> bool {\n    p.file_name().is_some() && p != std::path::Path::new(\"/\")\n}","typeGuard":"fn has_basename(p: &std::path::Path) -> bool {\n    p.file_name().map(|n| !n.is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match install(&pkg, &config) {\n    Err(e) if e.to_string().contains(\"base name of the installation path\") => {\n        eprintln!(\"cellar path is malformed (root/empty?); check PKGX_DIR\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Never set PKGX_DIR to / or an empty string","Validate configured paths have a final component before passing them to the library","When constructing Installation paths programmatically, always join a concrete directory name","Test installs with your exact environment (env vars) before scripting at scale"],"tags":["install","symlink","filesystem","path"],"backgroundTag":"file-not-found","analyzedSha":"6de1d7e953b98061f69db95d4bd45a2a6ee5d7da","analyzedAt":"2026-09-10T09:59:03.886Z","contentChangedAt":"2026-09-10T09:59:03.886Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}