zed-industries/zed · error
error building metal library
Error message
error building metal library
What it means
MetalRenderer::new_internal compiles the Metal shader library; the expect fires when library creation fails (invalid shader source, missing .metal files in the bundle, toolchain/driver problems). Without the library no rendering pipeline can be built, so startup aborts.
Source
Thrown at crates/gpui_apple/src/metal_renderer.rs:220
"Unable to enumerate Metal devices; attempting to use system default device"
);
metal::Device::system_default().unwrap_or_else(|| {
log::error!("unable to access a compatible graphics device");
std::process::exit(1);
})
}
}
fn new_internal(
device: metal::Device,
layer: Option<metal::MetalLayer>,
opaque: bool,
instance_buffer_pool: Arc<Mutex<InstanceBufferPool>>,
) -> Self {
#[cfg(feature = "runtime_shaders")]
let library = device
.new_library_with_source(&SHADERS_SOURCE_FILE, &metal::CompileOptions::new())
.expect("error building metal library");
#[cfg(not(feature = "runtime_shaders"))]
let library = device
.new_library_with_data(SHADERS_METALLIB)
.expect("error building metal library");
fn to_float2_bits(point: PointF) -> u64 {
let mut output = point.y.to_bits() as u64;
output <<= 32;
output |= point.x.to_bits() as u64;
output
}
// Shared memory can be used only if CPU and GPU share the same memory space.
// https://developer.apple.com/documentation/metal/setting-resource-storage-modes
let is_unified_memory = device.has_unified_memory();
// Apple GPU families support memoryless textures, which can significantly reduce
// memory usage by keeping render targets in on-chip tile memory instead of
// allocating backing store in system memory.View on GitHub (pinned to 9d272b0363)
Solutions
- Check the app bundle contains the compiled .metallib / .metal sources
- Run with runtime_shaders feature to bypass offline compilation issues
- Inspect the returned NSError from newLibraryWithSource for compile errors
- Update GPU drivers / macOS and verify Metal support
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/gpui_apple/src/metal_renderer.rs:220 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/ea61cf32afcbd010.
Report an issue: GitHub.