{"record":{"id":"ed413f34b74b6800","repo":"bevyengine/bevy","slug":"failed-to-create-file-path","errorCode":null,"errorMessage":"Failed to create {file_path:?}","messagePattern":"Failed to create (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_reflect/derive/src/impls/common.rs","lineNumber":220,"sourceCode":"        // To allow writing to this file from multiple threads during compilation it is protected by mutex.\n        // This static is valid for the duration of compilation of one crate and we have one file per crate,\n        // so it is enough to protect compilation threads from overwriting each other.\n        // This file is reset on every crate recompilation.\n        //\n        // It might make sense to replace the mutex with File::lock when file_lock feature becomes stable.\n        static REGISTRATION_FNS_EXPORT: LazyLock<Mutex<fs::File>> = LazyLock::new(|| {\n            let path = PathBuf::from(\"target\").join(\"bevy_reflect_type_registrations\");\n            fs::DirBuilder::new()\n                .recursive(true)\n                .create(&path)\n                .unwrap_or_else(|_| panic!(\"Failed to create {path:?}\"));\n            let file_path = path.join(env::var(\"CARGO_CRATE_NAME\").unwrap());\n            let file = fs::OpenOptions::new()\n                .create(true)\n                .write(true)\n                .truncate(true)\n                .open(&file_path)\n                .unwrap_or_else(|_| panic!(\"Failed to create {file_path:?}\"));\n            Mutex::new(file)\n        });\n\n        let export_name = format!(\"_bevy_reflect_register_{}\", uuid::Uuid::new_v4().as_u128());\n\n        {\n            let mut file = REGISTRATION_FNS_EXPORT.lock().unwrap();\n            writeln!(file, \"{export_name}\")\n                .unwrap_or_else(|_| panic!(\"Failed to write registration function {export_name}\"));\n            // We must sync_data to ensure all content is written before releasing the lock.\n            file.sync_data().unwrap();\n        };\n\n        Some(quote! {\n            /// # Safety\n            /// This function must only be used by the `load_type_registrations` macro.\n            #[unsafe(export_name=#export_name)]\n            pub unsafe extern \"Rust\" fn bevy_register_type(registry: &mut #bevy_reflect_path::TypeRegistry) {","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_reflect/derive/src/impls/common.rs#L202-L238","documentation":"Panic during auto-registration data export: the derive macro's generated code failed to create/open the per-crate registration-fns file under the build directory (keyed by CARGO_CRATE_NAME). Indicates a filesystem/environment problem at compile time (permissions, missing OUT_DIR).","triggerScenarios":"Thrown at crates/bevy_reflect/derive/src/impls/common.rs:220 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check filesystem permissions and disk space for the build directory","Clean the target directory and rebuild","Remove stale lock/scratch files left by a previous build"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}