{"record":{"id":"44e911008106c870","repo":"gfx-rs/wgpu","slug":"no-context-available-you-need-to-enable-one-of-wg","errorCode":null,"errorMessage":"No context available. You need to enable one of wgpu's backend feature build flags.","messagePattern":"No context available\\. You need to enable one of wgpu's backend feature build flags\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"wgpu/src/dispatch.rs","lineNumber":902,"sourceCode":"            fn from(value: $webgpu_type) -> Self {\n                Self::WebGPU(value)\n            }\n        }\n\n        impl core::ops::Deref for $name {\n            type Target = dyn $interface;\n\n            #[inline]\n            fn deref(&self) -> &Self::Target {\n                match self {\n                    #[cfg(wgpu_core)]\n                    Self::Core(value) => value,\n                    #[cfg(webgpu)]\n                    Self::WebGPU(value) => value,\n                    #[cfg(custom)]\n                    Self::Custom(value) => value.deref(),\n                    #[cfg(not(any(wgpu_core, webgpu)))]\n                    _ => panic!(\"No context available. You need to enable one of wgpu's backend feature build flags.\"),\n                }\n            }\n        }\n\n        explicit_send_sync_impl!($name);\n    };\n    (\n        mut type $name:ident: $interface:ident = $core_type:ident,$webgpu_type:ident,$custom_type:ident\n    ) => {\n        #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]\n        pub enum $name {\n            #[cfg(wgpu_core)]\n            Core($core_type),\n            #[cfg(webgpu)]\n            WebGPU($webgpu_type),\n            #[allow(clippy::allow_attributes, private_interfaces)]\n            #[cfg(custom)]\n            Custom($custom_type),","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/dispatch.rs#L884-L920","documentation":"This panic comes from the `Deref` implementation of the dispatch enums generated by `dispatch_types!` (wgpu/src/dispatch.rs:902). When wgpu is compiled with NEITHER the `wgpu_core` NOR the `webgpu` feature, every match arm is cfg'd out, so dereferencing any dispatch handle (or calling any trait method on it) has no variant to return and panics with 'No context available...'. wgpu requires at least one backend feature to function.","triggerScenarios":"Compiling the `wgpu` crate with all backend feature flags disabled (no `wgpu_core`, no `webgpu`), then constructing or using any wgpu resource (device, bind group, etc.) whose Deref hits the catch-all arm — e.g. running benches/benches/wgpu-benchmark/bind_groups.rs against a feature-less wgpu build.","commonSituations":"Dependending on wgpu with `default-features = false` and forgetting to add a backend feature; minimal/embedded builds trimming features; CI matrix configs that accidentally drop backend features; custom-backend setups that enable only `custom` plus cfg conditions not matching (though `custom` alone avoids this arm).","solutions":["Enable a backend feature in Cargo.toml: `wgpu = { features = [\"wgpu_core\"] }` (or `\"webgpu\"` for WASM)","If using `default-features = false`, re-enable defaults or explicitly list `wgpu_core`/`webgpu`","Verify with `cargo tree -e features -p wgpu` or `cargo metadata` that a backend feature is active in the resolved build","If a fully stubbed build is intended, guard all wgpu usage behind `#[cfg(any(wgpu_core, webgpu))]` so the panicking code is never compiled/called"],"exampleFix":"// before (Cargo.toml)\nwgpu = { version = \"24\", default-features = false }\n// after (Cargo.toml)\nwgpu = { version = \"24\", default-features = false, features = [\"wgpu_core\"] }","handlingStrategy":"validation","validationCode":"// Cargo.toml — verify a backend feature is enabled before building\n// wgpu = { features = [\"wgpu_core\"] }\n// CI check:\n// cargo metadata | jq '.packages[] | select(.name==\"wgpu\")'","typeGuard":null,"tryCatchPattern":"// Panic cannot be caught; guard at build time instead\n#[cfg(not(any(feature = \"wgpu_core\", feature = \"webgpu\")))]\ncompile_error!(\"Enable the wgpu_core or webgpu feature\");","preventionTips":["Never use default-features = false without re-adding a backend feature","Add a compile_error! guard for feature-less configurations","Run `cargo tree -e features` in CI to verify backend features resolve","Document required wgpu features in your crate's feature docs"],"tags":["panic","build-configuration","missing-feature","wgpu"],"backgroundTag":"missing-feature-flag","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}