oven-sh/bun · error
Patched dependency cache dir subpath does not have the…
Error message
Patched dependency cache dir subpath does not have the "_patch_hash=HASH" suffix. This is a bug, please file a GitHub issue.
What it means
Internal invariant violated: the patched dependency's cache directory subpath lacks the required '_patch_hash=HASH' suffix. This indicates a bug in Bun's patch cache path construction — patched packages must have their hash appended to the cache path to distinguish them from unpatched ones.
Solutions
- Report this as a GitHub issue at https://github.com/oven-sh/bun/issues with reproduction steps
- Try clearing the Bun cache (bun pm cache rm) and reinstalling
- Check that patchedDependencies in package.json uses the correct format
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/install/PackageInstall.rs:2265 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/1ab2cb46c7a2cfbe.
Report an issue: GitHub.
Appendix: source
Thrown at src/install/PackageInstall.rs:2265
manager: &mut PackageManager,
package_id: PackageID,
resolution_tag: resolution::Tag,
) -> bool {
let state = manager.get_preinstall_state(package_id);
match state {
crate::PreinstallState::Done => false,
_ => {
let exists = if self.patch.is_none() {
crate::package_manager::directories::is_package_in_cache_at(
self.cache_dir,
self.cache_dir_subpath,
resolution_tag,
)
} else {
let idx =
strings::last_index_of(self.cache_dir_subpath.as_bytes(), b"_patch_hash=")
.unwrap_or_else(|| {
panic!("Patched dependency cache dir subpath does not have the \"_patch_hash=HASH\" suffix. This is a bug, please file a GitHub issue.")
});
let non_patched =
bun_core::ZBox::from_bytes(&self.cache_dir_subpath.as_bytes()[..idx]);
crate::package_manager::directories::is_package_in_cache_at(
self.cache_dir,
&non_patched,
resolution_tag,
)
};
if exists {
manager.set_preinstall_state(package_id, crate::PreinstallState::Done);
}
!exists
}
}
}
pub(crate) fn patched_package_missing_from_cache(View on GitHub (pinned to 8c5296ac45)