asciinema/asciinema · error
bail!(e)
Error message
bail!(e)
What it means
read_install_id reads the install-id file and wraps any filesystem error other than NotFound with bail!(e). This means an I/O problem occurred while opening or reading the install id file (install-id in the state/config directory) and asciinema surfaces the raw std::io::Error message.
Source
Thrown at src/config.rs:192
fn parse_server_url(s: &str) -> Result<Url> {
let url = Url::parse(s)?;
if url.host().is_none() {
bail!("server URL is missing a host");
}
Ok(url)
}
fn read_install_id(path: &PathBuf) -> Result<Option<String>> {
match fs::read_to_string(path) {
Ok(s) => Ok(Some(s.trim().to_string())),
Err(e) => {
if e.kind() == ErrorKind::NotFound {
Ok(None)
} else {
bail!(e)
}
}
}
}
fn generate_install_id() -> String {
Uuid::new_v4().to_string()
}
fn save_install_id(path: &PathBuf, id: &str) -> Result<()> {
if let Some(dir) = path.parent() {
fs::create_dir_all(dir)?;
}
fs::write(path, id)?;
Ok(())
}View on GitHub (pinned to 7749806198)
Solutions
- Fix permissions on the install-id file (chmod/chown) so the current user can read it
- If the path is wrong (e.g. a directory), delete it so asciinema can regenerate a fresh install id
- Check env vars ASCIINEMA_CONFIG_HOME / XDG_STATE_HOME / HOME don't point to unreadable locations
Example fix
// before $ ls -l ~/.local/state/asciinema/install-id # root-owned, mode 600 // after $ sudo chown $USER ~/.local/state/asciinema/install-id && chmod 600 ~/.local/state/asciinema/install-id
Defensive patterns
Strategy: try-catch
Validate before calling
let path = state_dir.join("install-id");
if path.exists() && !path.is_file() {
return Err(format!("{} is not a regular file", path.display()));
} Try / catch
match std::fs::read_to_string(&install_id_path) {
Ok(s) => Some(s.trim().to_string()),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => None,
Err(e) => { eprintln!("cannot read install id: {e}"); std::process::exit(1); }
} Prevention
- Keep state/config directories owned and writable by the running user
- Never run only one command with sudo against the same state dir
- Ensure HOME/XDG dirs are on a local, readable filesystem
When it happens
Trigger: Calling get_install_id when the install-id file exists but cannot be read: e.g. PermissionDenied on ~/.local/state/asciinema/install-id, IsADirectory where the file should be, or other non-NotFound io::ErrorKind values.
Common situations: Restrictive permissions after running asciinema as another user (root vs user), a directory accidentally created at the install-id path, filesystem errors on NFS/synced folders, or SELinux/AppArmor denials.
Related errors
- can't open {}: {}
- cannot open log file {}: {}
- server URL is missing a host
- need $HOME or $XDG_CONFIG_HOME or $ASCIINEMA_CONFIG_HOME
- need $HOME or $XDG_STATE_HOME or $ASCIINEMA_STATE_HOME
AI-assisted analysis of asciinema/asciinema@7749806198 (2026-09-03).
Data as JSON: /api/errors/c329206b7bf38dce.
Report an issue: GitHub.