{"record":{"id":"53e4c6c5d8341a7c","repo":"sxyazi/yazi","slug":"cannot-create-a-disk-arbitration-session","errorCode":null,"errorMessage":"Cannot create a disk arbitration session","messagePattern":"Cannot create a disk arbitration session","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fs/src/mounts/macos.rs","lineNumber":98,"sourceCode":"\t\t\tif let Err(ref e) = result {\n\t\t\t\terror!(\"Error encountered while updating mount points: {e:?}\");\n\t\t\t}\n\n\t\t\tlet mut guard = me.write();\n\t\t\tif let Ok(new) = result {\n\t\t\t\tguard.inner = new;\n\t\t\t}\n\t\t\tguard.need_update = false;\n\n\t\t\tdrop(guard);\n\t\t\tcb();\n\t\t});\n\t}\n\n\tfn all_partitions(names: Vec<CString>) -> Result<Vec<Partition>> {\n\t\tlet session = unsafe { DASessionCreate(kCFAllocatorDefault) };\n\t\tif session.is_null() {\n\t\t\tbail!(\"Cannot create a disk arbitration session\");\n\t\t}\n\t\tdefer! { unsafe { CFRelease(session) } };\n\n\t\tlet mut disks = Vec::with_capacity(names.len());\n\t\tfor name in names {\n\t\t\tlet disk = unsafe { DADiskCreateFromBSDName(kCFAllocatorDefault, session, name.as_ptr()) };\n\t\t\tif disk.is_null() {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tdefer! { unsafe { CFRelease(disk) } };\n\t\t\tlet Ok(dict) = CFDict::take(unsafe { DADiskCopyDescription(disk) }) else {\n\t\t\t\tcontinue;\n\t\t\t};\n\n\t\t\tlet partition = Partition::new(&OsString::from_vec(name.into_bytes()));\n\t\t\tlet rdev = std::fs::metadata(&partition.src).map(|m| m.rdev() as _).ok();\n\t\t\tdisks.push(Partition {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/mounts/macos.rs#L80-L116","documentation":"In yazi-fs's macOS mount enumeration, `all_partitions` calls the DiskArbitration C API `DASessionCreate`; when it returns NULL the code bails with this message. A DA session is the handle required to create `DADisk` objects from BSD device names, so without it mount info cannot be gathered. This indicates the DiskArbitration framework failed to allocate/initialize a session, which is essentially never expected in a normal desktop process.","triggerScenarios":"Calling `all_partitions(Vec<CString>)` on macOS when `unsafe { DASessionCreate(kCFAllocatorDefault) }` returns a null pointer (e.g. `CFNotificationCenter`/DiskArbitration unavailable, allocator exhaustion, or running in a sandbox/environment where the framework cannot initialize).","commonSituations":"Running yazi inside heavily restricted sandboxes or exotic environments (jail-like setups, stripped macOS runtimes, CI VMs without a proper launchd session) where DiskArbitration services are unavailable; extremely low memory; linking against a broken/patched system framework.","solutions":["Run the binary in a normal macOS user session (not a heavily sandboxed or stripped environment) so DiskArbitration is reachable.","Check memory pressure / allocator failures; retry after freeing resources.","Verify the app bundle/environment isn't blocking framework loads (e.g. DYLD restrictions, sandbox entitlements).","If unavoidable, degrade gracefully: treat mount enumeration as unavailable and show partitions without DA-based metadata."],"exampleFix":"// before\nlet session = unsafe { DASessionCreate(kCFAllocatorDefault) };\nif session.is_null() {\n    bail!(\"Cannot create a disk arbitration session\");\n}\n// after: fall back to empty list instead of hard error\nlet session = unsafe { DASessionCreate(kCFAllocatorDefault) };\nif session.is_null() {\n    tracing::warn!(\"DiskArbitration unavailable; skipping mount info\");\n    return Ok(Vec::new());\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"fn has_da_session() -> bool {\n    !unsafe { core_foundation::base::CFBridgingRetain(()) }.is_null() // placeholder; instead:\n}\n// practical pre-check: probe once\nlet probe = unsafe { DASessionCreate(kCFAllocatorDefault) };\nlet da_available = !probe.is_null();\nif !probe.is_null() { unsafe { CFRelease(probe) }; }","tryCatchPattern":"match all_partitions(names) {\n    Ok(parts) => parts,\n    Err(e) if e.to_string().contains(\"disk arbitration session\") => Vec::new(), // degrade\n    Err(e) => return Err(e),\n}","preventionTips":["Run inside a normal macOS user session without sandbox restrictions on DiskArbitration.","Probe DiskArbitration availability once at startup and cache the result.","Provide a non-DA fallback partition listing for restricted environments."],"tags":["macos","diskarbitration","ffi","mounts"],"backgroundTag":"disk-arbitration-session-failed","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}