{"record":{"id":"c329206b7bf38dce","repo":"asciinema/asciinema","slug":"bail-e","errorCode":null,"errorMessage":"bail!(e)","messagePattern":"bail!\\(e\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config.rs","lineNumber":192,"sourceCode":"fn parse_server_url(s: &str) -> Result<Url> {\n    let url = Url::parse(s)?;\n\n    if url.host().is_none() {\n        bail!(\"server URL is missing a host\");\n    }\n\n    Ok(url)\n}\n\nfn read_install_id(path: &PathBuf) -> Result<Option<String>> {\n    match fs::read_to_string(path) {\n        Ok(s) => Ok(Some(s.trim().to_string())),\n\n        Err(e) => {\n            if e.kind() == ErrorKind::NotFound {\n                Ok(None)\n            } else {\n                bail!(e)\n            }\n        }\n    }\n}\n\nfn generate_install_id() -> String {\n    Uuid::new_v4().to_string()\n}\n\nfn save_install_id(path: &PathBuf, id: &str) -> Result<()> {\n    if let Some(dir) = path.parent() {\n        fs::create_dir_all(dir)?;\n    }\n\n    fs::write(path, id)?;\n\n    Ok(())\n}","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/asciinema/asciinema/blob/77498061982889f68ba1f6e8b666dd8d13246250/src/config.rs#L174-L210","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n$ ls -l ~/.local/state/asciinema/install-id  # root-owned, mode 600\n// after\n$ sudo chown $USER ~/.local/state/asciinema/install-id && chmod 600 ~/.local/state/asciinema/install-id","handlingStrategy":"try-catch","validationCode":"let path = state_dir.join(\"install-id\");\nif path.exists() && !path.is_file() {\n    return Err(format!(\"{} is not a regular file\", path.display()));\n}","typeGuard":null,"tryCatchPattern":"match std::fs::read_to_string(&install_id_path) {\n    Ok(s) => Some(s.trim().to_string()),\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => None,\n    Err(e) => { eprintln!(\"cannot read install id: {e}\"); std::process::exit(1); }\n}","preventionTips":["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"],"tags":["filesystem","io","permissions","rust"],"backgroundTag":"io-error-permission-denied","analyzedSha":"77498061982889f68ba1f6e8b666dd8d13246250","analyzedAt":"2026-09-03T06:12:25.119Z","contentChangedAt":"2026-09-03T06:12:25.119Z","schemaVersion":2},"datasetVersion":"2026-09-10T12:17:11.382Z"}