oven-sh/bun · error
Failed to load '{}': {e} To improve iteration speed, some f
Error message
Failed to load '{}': {e}
To 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. What it means
Error "Failed to load '{}': {e} To 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.
Source
Thrown at src/bun_core/util.rs:2960
#[doc(hidden)]
pub fn __runtime_embed_load(kind: EmbedKind, sub: &'static str) -> String {
// SAFETY: CODEGEN_PATH/BASE_PATH originate from `option_env!` (`&'static str`
// → bytes), so the bytes are valid UTF-8 by construction.
let from = |b: &'static [u8]| unsafe { ::core::str::from_utf8_unchecked(b) };
let mut p = match kind {
EmbedKind::Codegen | EmbedKind::CodegenEager => {
::std::path::PathBuf::from(from(crate::build_options::CODEGEN_PATH))
}
EmbedKind::Src | EmbedKind::SrcEager => {
let mut b = ::std::path::PathBuf::from(from(crate::build_options::BASE_PATH));
b.push("src");
b
}
};
p.push(sub);
::std::fs::read_to_string(&p).unwrap_or_else(|e| {
panic!(
"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.",
p.display(),
)
})
}
/// Per-call-site embedded file.
/// `$root` must be one of the bare idents `Codegen` /
/// `CodegenEager` / `Src` / `SrcEager` and `$sub_path` a string literal.
///
/// The `cfg(bun_codegen_embed)` split lives **inside** the macro so call
/// sites never repeat the `#[cfg]`/`#[cfg(not)]` pair (which is error-prone
/// — a missed pair leaves a release binary that panics with "Failed to load
/// '<build-machine-path>/…'"). Under the cfg, the file is `include_str!`-ed
/// at compile time; otherwise it's read once at runtime into a per-site
/// `OnceLock<String>` for fast iteration.
///
/// `Src` paths are relative to `<repo>/src/`; `Codegen` paths are relativeView on GitHub (pinned to 8c5296ac45)
When it happens
Trigger: Thrown at src/bun_core/util.rs:2960 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/e9a528fa4ac52750.
Report an issue: GitHub.