atuinsh/atuin · error
Could not find history directory {p:?}. Try setting and expo
Error message
Could not find history directory {p:?}. Try setting and exporting $HISTFILE What it means
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.
Source
Thrown at crates/atuin-client/src/import/mod.rs:114
fn read_to_end(path: PathBuf) -> Result<Vec<u8>> {
let mut bytes = Vec::new();
let mut f = File::open(path)?;
f.read_to_end(&mut bytes)?;
Ok(bytes)
}
fn is_file(p: PathBuf) -> Result<PathBuf> {
if p.is_file() {
Ok(p)
} else {
bail!("Could not find history file {:?}. Try setting and exporting $HISTFILE", p);
}
}
fn is_dir(p: PathBuf) -> Result<PathBuf> {
if p.is_dir() {
Ok(p)
} else {
bail!("Could not find history directory {:?}. Try setting and exporting $HISTFILE", p);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[derive(Default)]
pub struct TestLoader {
pub buf: Vec<History>,
}
#[async_trait]
impl Loader for TestLoader {
async fn push(&mut self, hist: History) -> Result<()> {
self.buf.push(hist);
Ok(())
}View on GitHub (pinned to c0c717ab04)
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
Example fix
// before atuin import zsh --dir ~/wrong_hist // after atuin import zsh --dir ~/.local/share/zsh/history
Defensive patterns
Strategy: validation
Validate before calling
const d = std::env::var("HISTFILE").unwrap_or_default();
if !std::path::Path::new(&d).is_dir() {
eprintln!("Expected a directory at HISTFILE path; check shell history layout");
} Type guard
fn history_dir_ok(p: &str) -> bool {
std::path::Path::new(p).is_dir()
} Try / catch
match is_dir(path) {
Ok(d) => import_dir(d),
Err(e) => eprintln!("{e}; point the import at the correct history directory"),
} Prevention
- Confirm your shell's history storage layout (file vs directory) before choosing the import target
- Create the history directory on fresh machines before importing
When it happens
Trigger: 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.
Common situations: $HISTFILE pointing at a file when the importer needs a directory; typo'd or non-existent history directory on a new machine.
Related errors
- Could not find history file {p:?}. Try setting and exporting
- key file vanished immediately after a concurrent write
AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12).
Data as JSON: /api/errors/8c32495732260bd9.
Report an issue: GitHub.