{"record":{"id":"8c32495732260bd9","repo":"atuinsh/atuin","slug":"could-not-find-history-directory-p-try-setting-and-exporting","errorCode":null,"errorMessage":"Could not find history directory {p:?}. Try setting and exporting $HISTFILE","messagePattern":"Could not find history directory (.+?)\\. Try setting and exporting \\$HISTFILE","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-client/src/import/mod.rs","lineNumber":114,"sourceCode":"\nfn read_to_end(path: PathBuf) -> Result<Vec<u8>> {\n    let mut bytes = Vec::new();\n    let mut f = File::open(path)?;\n    f.read_to_end(&mut bytes)?;\n    Ok(bytes)\n}\nfn is_file(p: PathBuf) -> Result<PathBuf> {\n    if p.is_file() {\n        Ok(p)\n    } else {\n        bail!(\"Could not find history file {:?}. Try setting and exporting $HISTFILE\", p);\n    }\n}\nfn is_dir(p: PathBuf) -> Result<PathBuf> {\n    if p.is_dir() {\n        Ok(p)\n    } else {\n        bail!(\"Could not find history directory {:?}. Try setting and exporting $HISTFILE\", p);\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[derive(Default)]\n    pub struct TestLoader {\n        pub buf: Vec<History>,\n    }\n\n    #[async_trait]\n    impl Loader for TestLoader {\n        async fn push(&mut self, hist: History) -> Result<()> {\n            self.buf.push(hist);\n            Ok(())\n        }","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin-client/src/import/mod.rs#L96-L132","documentation":"is_dir validates that the given path is an existing directory before directory-based import; if not, it fails with guidance referencing $HISTFILE. Thrown when a history directory path is missing or is a plain file.","triggerScenarios":"Running a directory-based history import (e.g. 'atuin import zsh' against Zsh's HISTDIR-style layouts) with a path that is not a directory — missing dir or a file passed instead.","commonSituations":"$HISTFILE pointing at a file when the importer needs a directory; typo'd or non-existent history directory on a new machine.","solutions":["Verify the path is an existing directory (ls -d) and fix it","Export the correct HISTFILE/HISTORY_PATH for your shell before importing","Create the directory if your shell layout expects it"],"exampleFix":"// before\natuin import zsh --dir ~/wrong_hist\n// after\natuin import zsh --dir ~/.local/share/zsh/history","handlingStrategy":"validation","validationCode":"const d = std::env::var(\"HISTFILE\").unwrap_or_default();\nif !std::path::Path::new(&d).is_dir() {\n    eprintln!(\"Expected a directory at HISTFILE path; check shell history layout\");\n}","typeGuard":"fn history_dir_ok(p: &str) -> bool {\n    std::path::Path::new(p).is_dir()\n}","tryCatchPattern":"match is_dir(path) {\n    Ok(d) => import_dir(d),\n    Err(e) => eprintln!(\"{e}; point the import at the correct history directory\"),\n}","preventionTips":["Confirm your shell's history storage layout (file vs directory) before choosing the import target","Create the history directory on fresh machines before importing"],"tags":["filesystem","import","env"],"backgroundTag":"directory-not-found","analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}