atuinsh/atuin · error
Could not find history file
Error message
Could not find history file {:?}. Try setting and exporting $HISTFILE What it means
`is_file` (atuin-client/src/import/mod.rs) validates that a resolved history path is a regular file before import; if `p.is_file()` is false it bails with "Could not find history file ... Try setting and exporting $HISTFILE". It is raised during history import when the configured/derived shell history file does not exist at the given path.
Solutions
- `touch` the history file or open an interactive shell once so it is created
- Export HISTFILE (e.g. `export HISTFILE=~/.bash_history`) before running atuin import
- Pass the correct history path explicitly to the import command
- Verify which file the importer expects and check it exists with `ls`
Example fix
// before atuin import auto // error: Could not find history file "/home/user/.bash_history" // after touch ~/.bash_history && atuin import auto // or export HISTFILE="$HOME/.zsh_history" && atuin import auto
Defensive patterns
Strategy: validation
Validate before calling
// check before import
let hf = std::env::var("HISTFILE").unwrap_or_else(|_| default_history_path());
if !std::path::Path::new(&hf).is_file() {
eprintln!("history file {hf} missing; export HISTFILE or touch it");
} Type guard
fn is_existing_file(p: &std::path::Path) -> bool { p.is_file() } Try / catch
match atuin_import_history().await {
Err(e) if e.to_string().contains("Could not find history file") => {
eprintln!("Set HISTFILE to your shell history path and retry");
}
other => other?,
} Prevention
- Export HISTFILE in your shell profile, not just set it locally
- Launch an interactive shell once so the history file is created
- Verify history file paths before running imports in scripts/CI
When it happens
Trigger: Running `atuin import ...` (e.g. auto import) when $HISTFILE points to a missing file, or the default history path for the detected shell does not exist on this machine.
Common situations: Fresh shell installation where the history file was never created; HISTFILE set in .zshrc/.bashrc but not exported into the environment atuin sees; running atuin from a context (cron, CI) without the interactive shell's env; shell name autodetection picking a shell whose default path is absent.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Could not find history directory
- Could not find history directory
- Could not find history file
- default socket path always has a parent
- key file vanished immediately after a concurrent write
AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19).
Data as JSON: /api/errors/73281a45675fffbf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/atuin-client/src/import/mod.rs:107
fn get_histdir_path<D>(def: D) -> Result<PathBuf>
where
D: FnOnce() -> Result<PathBuf>,
{
get_histpath(def).and_then(is_dir)
}
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>,
}View on GitHub (pinned to 900007c480)