sxyazi/yazi · error

Cannot create a disk arbitration session

Error message

Cannot create a disk arbitration session

What it means

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.

Source

Thrown at yazi-fs/src/mounts/macos.rs:98

			if let Err(ref e) = result {
				error!("Error encountered while updating mount points: {e:?}");
			}

			let mut guard = me.write();
			if let Ok(new) = result {
				guard.inner = new;
			}
			guard.need_update = false;

			drop(guard);
			cb();
		});
	}

	fn all_partitions(names: Vec<CString>) -> Result<Vec<Partition>> {
		let session = unsafe { DASessionCreate(kCFAllocatorDefault) };
		if session.is_null() {
			bail!("Cannot create a disk arbitration session");
		}
		defer! { unsafe { CFRelease(session) } };

		let mut disks = Vec::with_capacity(names.len());
		for name in names {
			let disk = unsafe { DADiskCreateFromBSDName(kCFAllocatorDefault, session, name.as_ptr()) };
			if disk.is_null() {
				continue;
			}

			defer! { unsafe { CFRelease(disk) } };
			let Ok(dict) = CFDict::take(unsafe { DADiskCopyDescription(disk) }) else {
				continue;
			};

			let partition = Partition::new(&OsString::from_vec(name.into_bytes()));
			let rdev = std::fs::metadata(&partition.src).map(|m| m.rdev() as _).ok();
			disks.push(Partition {

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Run the binary in a normal macOS user session (not a heavily sandboxed or stripped environment) so DiskArbitration is reachable.
  2. Check memory pressure / allocator failures; retry after freeing resources.
  3. Verify the app bundle/environment isn't blocking framework loads (e.g. DYLD restrictions, sandbox entitlements).
  4. If unavoidable, degrade gracefully: treat mount enumeration as unavailable and show partitions without DA-based metadata.

Example fix

// before
let session = unsafe { DASessionCreate(kCFAllocatorDefault) };
if session.is_null() {
    bail!("Cannot create a disk arbitration session");
}
// after: fall back to empty list instead of hard error
let session = unsafe { DASessionCreate(kCFAllocatorDefault) };
if session.is_null() {
    tracing::warn!("DiskArbitration unavailable; skipping mount info");
    return Ok(Vec::new());
}
Defensive patterns

Strategy: fallback

Type guard

fn has_da_session() -> bool {
    !unsafe { core_foundation::base::CFBridgingRetain(()) }.is_null() // placeholder; instead:
}
// practical pre-check: probe once
let probe = unsafe { DASessionCreate(kCFAllocatorDefault) };
let da_available = !probe.is_null();
if !probe.is_null() { unsafe { CFRelease(probe) }; }

Try / catch

match all_partitions(names) {
    Ok(parts) => parts,
    Err(e) if e.to_string().contains("disk arbitration session") => Vec::new(), // degrade
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/53e4c6c5d8341a7c. Report an issue: GitHub.