{"record":{"id":"ea61cf32afcbd010","repo":"zed-industries/zed","slug":"error-building-metal-library","errorCode":null,"errorMessage":"error building metal library","messagePattern":"error building metal library","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_apple/src/metal_renderer.rs","lineNumber":220,"sourceCode":"                \"Unable to enumerate Metal devices; attempting to use system default device\"\n            );\n            metal::Device::system_default().unwrap_or_else(|| {\n                log::error!(\"unable to access a compatible graphics device\");\n                std::process::exit(1);\n            })\n        }\n    }\n\n    fn new_internal(\n        device: metal::Device,\n        layer: Option<metal::MetalLayer>,\n        opaque: bool,\n        instance_buffer_pool: Arc<Mutex<InstanceBufferPool>>,\n    ) -> Self {\n        #[cfg(feature = \"runtime_shaders\")]\n        let library = device\n            .new_library_with_source(&SHADERS_SOURCE_FILE, &metal::CompileOptions::new())\n            .expect(\"error building metal library\");\n        #[cfg(not(feature = \"runtime_shaders\"))]\n        let library = device\n            .new_library_with_data(SHADERS_METALLIB)\n            .expect(\"error building metal library\");\n\n        fn to_float2_bits(point: PointF) -> u64 {\n            let mut output = point.y.to_bits() as u64;\n            output <<= 32;\n            output |= point.x.to_bits() as u64;\n            output\n        }\n\n        // Shared memory can be used only if CPU and GPU share the same memory space.\n        // https://developer.apple.com/documentation/metal/setting-resource-storage-modes\n        let is_unified_memory = device.has_unified_memory();\n        // Apple GPU families support memoryless textures, which can significantly reduce\n        // memory usage by keeping render targets in on-chip tile memory instead of\n        // allocating backing store in system memory.","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_apple/src/metal_renderer.rs#L202-L238","documentation":"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.","triggerScenarios":"Thrown at crates/gpui_apple/src/metal_renderer.rs:220 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}