atuinsh/atuin · error
Failed to get current PID
Error message
Failed to get current PID
What it means
A panic in Shell::current (atuin-common) when sysinfo's get_current_pid() returns an error, i.e. the platform cannot report Atuin's own process ID. Shell::current walks sysinfo's process table to find its parent process (the shell that invoked Atuin) and derive the shell from its name; the very first step, obtaining its own PID, is unwrapped with expect. It is a platform-support failure in sysinfo, not something config or usage causes — and note the sibling expects after it ('Atuin running with no parent!', process lookup) can equally abort exotic setups.
Source
Thrown at crates/atuin-common/src/shell.rs:41
#[display("unknown")]
Unknown,
}
#[derive(Debug, Error, Serialize)]
pub enum ShellError {
#[error("shell not supported")]
NotSupported,
#[error("failed to execute shell command: {0}")]
ExecError(String),
}
impl Shell {
pub fn current() -> Shell {
let sys = System::new_all();
let process = sys
.process(get_current_pid().expect("Failed to get current PID"))
.expect("Process with current pid does not exist");
let parent = sys
.process(process.parent().expect("Atuin running with no parent!"))
.expect("Process with parent pid does not exist");
let shell = parent.name().trim().to_lowercase();
let shell = shell.strip_prefix('-').unwrap_or(&shell);
Shell::from_string(shell.to_string())
}
pub fn from_env() -> Shell {
std::env::var("ATUIN_SHELL").map_or(Shell::Unknown, |shell| {
Shell::from_string(shell.trim().to_lowercase())
})
}
View on GitHub (pinned to 202f6ad98e)
Solutions
- Set the ATUIN_SHELL environment variable to your shell name and prefer Shell::from_env(), which reads it without any process-table walk
- Run on a platform sysinfo supports (any mainstream Linux/macOS/Windows/BSD)
- Fix the sandbox/container so /proc is mounted and readable
- In embedding code, call Shell::from_env() or Shell::from_string() instead of Shell::current() to avoid the panic path entirely
Example fix
// before
let shell = Shell::current(); // panics if sysinfo cannot get our PID
// after
let shell = std::env::var("ATUIN_SHELL")
.map(|s| Shell::from_string(s.trim().to_lowercase()))
.unwrap_or_else(|_| Shell::current()); Defensive patterns
Strategy: fallback
Validate before calling
// Prefer environment-based detection; only fall back to process introspection
std::env::set_var("ATUIN_SHELL", "zsh"); // set in shell init files before invoking atuin
let shell = Shell::from_env(); // never panics: Unknown when var absent Type guard
fn shell_detectable() -> bool {
// sysinfo needs a readable /proc (linux) or supported process API
cfg!(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "freebsd"))
&& std::path::Path::new("/proc").exists() || cfg!(not(target_os = "linux"))
} Try / catch
// expect() panic: not catchable as an error. Avoid the panic path by preferring // Shell::from_env() (reads ATUIN_SHELL, returns Shell::Unknown instead of panicking) // or Shell::from_string(name) when the caller already knows the shell.
Prevention
- Export ATUIN_SHELL in your shell's init file so Atuin never needs process introspection
- Use Shell::from_env()/from_string() instead of Shell::current() in embedding code
- Ensure /proc is mounted and readable in containers/sandboxes running Atuin
- Verify sysinfo supports your platform before porting
When it happens
Trigger: Running Shell::current() on a platform/target where sysinfo cannot enumerate processes or provide the current PID (some containers, sandboxes, wasm, or Tier-3 OS targets); typically during shell-hook init or commands that need to detect the invoking shell.
Common situations: Running Atuin inside minimal sandboxes or exotic emulated environments where /proc is absent or process introspection is blocked; cross-compiled builds on unsupported operating systems.
Related errors
- Interactive mode requires a terminal
- bug in list query. please report
- bug in search query. please report
- issue in stats previous query
- issue in stats next query
AI-assisted analysis of atuinsh/atuin@202f6ad98e (2026-08-16).
Data as JSON: /api/errors/91886c19964bd619.
Report an issue: GitHub.