{"record":{"id":"e9a528fa4ac52750","repo":"oven-sh/bun","slug":"failed-to-load-e-to-improve-iteration-spe","errorCode":null,"errorMessage":"Failed to load '{}': {e}\n\nTo improve iteration speed, some files are not embedded but loaded at runtime, at the cost of making the binary non-portable. To fix this, build with codegen_embed.","messagePattern":"Failed to load '(.+?)': (.+?)\n\nTo improve iteration speed, some files are not embedded but loaded at runtime, at the cost of making the binary non-portable\\. To fix this, build with codegen_embed\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bun_core/util.rs","lineNumber":2960,"sourceCode":"\n#[doc(hidden)]\npub fn __runtime_embed_load(kind: EmbedKind, sub: &'static str) -> String {\n    // SAFETY: CODEGEN_PATH/BASE_PATH originate from `option_env!` (`&'static str`\n    // → bytes), so the bytes are valid UTF-8 by construction.\n    let from = |b: &'static [u8]| unsafe { ::core::str::from_utf8_unchecked(b) };\n    let mut p = match kind {\n        EmbedKind::Codegen | EmbedKind::CodegenEager => {\n            ::std::path::PathBuf::from(from(crate::build_options::CODEGEN_PATH))\n        }\n        EmbedKind::Src | EmbedKind::SrcEager => {\n            let mut b = ::std::path::PathBuf::from(from(crate::build_options::BASE_PATH));\n            b.push(\"src\");\n            b\n        }\n    };\n    p.push(sub);\n    ::std::fs::read_to_string(&p).unwrap_or_else(|e| {\n        panic!(\n            \"Failed to load '{}': {e}\\n\\nTo improve iteration speed, some files are not embedded but loaded at runtime, at the cost of making the binary non-portable. To fix this, build with codegen_embed.\",\n            p.display(),\n        )\n    })\n}\n\n/// Per-call-site embedded file.\n/// `$root` must be one of the bare idents `Codegen` /\n/// `CodegenEager` / `Src` / `SrcEager` and `$sub_path` a string literal.\n///\n/// The `cfg(bun_codegen_embed)` split lives **inside** the macro so call\n/// sites never repeat the `#[cfg]`/`#[cfg(not)]` pair (which is error-prone\n/// — a missed pair leaves a release binary that panics with \"Failed to load\n/// '<build-machine-path>/…'\"). Under the cfg, the file is `include_str!`-ed\n/// at compile time; otherwise it's read once at runtime into a per-site\n/// `OnceLock<String>` for fast iteration.\n///\n/// `Src` paths are relative to `<repo>/src/`; `Codegen` paths are relative","sourceCodeStart":2942,"sourceCodeEnd":2978,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/bun_core/util.rs#L2942-L2978","documentation":"Error \"Failed to load '{}': {e}\n\nTo improve iteration speed, some files are not embedded but loaded at runtime, at the cost of making the binary non-portable. To fix this, build with codegen_embed.\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/bun_core/util.rs:2960 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}