{"record":{"id":"9387e1251ddfc776","repo":"BoundaryML/baml","slug":"io-error-0-9387e1","errorCode":null,"errorMessage":"IO error: {0}","messagePattern":"IO error: (.+?)","errorType":"exception","errorClass":"BamlSysError","httpStatus":null,"severity":"error","filePath":"languages/rust/baml-sys/src/error.rs","lineNumber":53,"sourceCode":"    UnsupportedPlatform {\n        os: &'static str,\n        arch: &'static str,\n    },\n\n    /// Failed to determine cache directory.\n    #[error(\"Failed to determine cache directory: {0}\")]\n    CacheDir(String),\n\n    /// Download failed.\n    #[error(\"Failed to download library: {0}\")]\n    DownloadFailed(String),\n\n    /// Checksum mismatch after download.\n    #[error(\"Checksum mismatch: expected {expected}, got {actual}\")]\n    ChecksumMismatch { expected: String, actual: String },\n\n    /// IO error.\n    #[error(\"IO error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    /// Library already initialized with different path.\n    #[error(\"Library already initialized from {existing_path}, cannot change to {requested_path}\")]\n    AlreadyInitialized {\n        existing_path: PathBuf,\n        requested_path: PathBuf,\n    },\n}\n\n/// Result type for baml-sys operations.\npub type Result<T> = std::result::Result<T, BamlSysError>;\n","sourceCodeStart":35,"sourceCodeEnd":66,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/languages/rust/baml-sys/src/error.rs#L35-L66","documentation":"A generic std::io::Error occurred during baml-sys library-loading operations and was converted into this variant via #[from]. Typical sources include failing to create the cache directory, failing to read/write the downloaded library file, or filesystem permission problems. The wrapped message describes the underlying OS error.","triggerScenarios":"Cache directory cannot be created (permissions, read-only filesystem, disk full), the downloaded library file cannot be written or read back, or file metadata/hashing reads fail with an OS error.","commonSituations":"Read-only container filesystems, running as a user without write access to the cache path, disk-quota exhaustion, or antivirus/EDR locking the downloaded .so/.dll/.dylib file.","solutions":["Check and fix permissions on the cache directory (or point it somewhere writable)","Free disk space if the filesystem is full","Check dmesg/audit logs for filesystem errors or EDR interference","Run with strace or enable logging to see which file operation fails","Ensure the cache parent directory exists and is writable by the running user"],"exampleFix":"// before\n# running as nobody with read-only /home\n// after\nexport XDG_CACHE_HOME=/tmp/baml-cache\nmkdir -p /tmp/baml-cache","handlingStrategy":"try-catch","validationCode":"let cache = std::env::var_os(\"XDG_CACHE_HOME\")\n    .or_else(|| std::env::var_os(\"HOME\").map(|h| h.join(\".cache\").into()))\n    .expect(\"no cache location\");\nlet md = std::fs::metadata(&cache)?;\nassert!(!md.permissions().readonly(), \"cache dir is read-only\");","typeGuard":"fn cache_writable() -> bool {\n    std::env::var_os(\"HOME\")\n        .or_else(|| std::env::var_os(\"XDG_CACHE_HOME\"))\n        .and_then(|p| std::fs::create_dir_all(&p).ok().map(|_| true))\n        .unwrap_or(false)\n}","tryCatchPattern":"match baml_sys::init() {\n    Err(BamlSysError::Io(e)) if e.kind() == std::io::ErrorKind::PermissionDenied => {\n        eprintln!(\"cache path not writable: {e}; set XDG_CACHE_HOME\");\n    }\n    Err(BamlSysError::Io(e)) if e.kind() == std::io::ErrorKind::StorageFull => {\n        eprintln!(\"disk full: {e}\");\n    }\n    other => other.map(|_| ())?,\n}","preventionTips":["Ensure the cache directory exists and is writable before first use","Mount writable volumes for cache paths in containers","Monitor disk space on machines running the app","Exclude the cache directory from antivirus real-time scanning"],"tags":["rust","io","filesystem","permissions","native-library"],"backgroundTag":"file-write-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}