oven-sh/bun · error

Expected folder path to contain `patch_hash=`, this is a bug

Error message

Expected folder path to contain `patch_hash=`, this is a bug in Bun. Please file a GitHub issue.

What it means

Error "Expected folder path to contain `patch_hash=`, this is a bug in Bun. Please file a GitHub issue." thrown in oven-sh/bun.

Source

Thrown at src/install/PackageManager/PackageManagerLifecycle.rs:182

                    directories::is_package_in_cache(self, folder_path, pkg.resolution.tag)
                };
                if in_cache {
                    self.set_preinstall_state(pkg.meta.id, PreinstallState::Done);
                    return PreinstallState::Done;
                }

                // If the package is patched, then `folder_path` looks like:
                // is-even@1.0.0_patch_hash=abc8s6dedhsddfkahaldfjhlj
                //
                // If that's not in the cache, we need to put it there:
                // 1. extract the non-patched pkg in the cache
                // 2. copy non-patched pkg into temp dir
                // 3. apply patch to temp dir
                // 4. rename temp dir to `folder_path`
                if patch_hash.is_some() {
                    let idx = strings::index_of(folder_path.as_bytes(), b"_patch_hash=")
                        .unwrap_or_else(|| {
                            panic!(
                                "Expected folder path to contain `patch_hash=`, this is a bug in \
                                 Bun. Please file a GitHub issue."
                            )
                        });
                    // Owned NUL-terminated copy.
                    let non_patched_path = ZBox::from_bytes(&folder_path.as_bytes()[..idx]);
                    if directories::is_package_in_cache(self, &non_patched_path, pkg.resolution.tag)
                    {
                        self.set_preinstall_state(pkg.meta.id, PreinstallState::ApplyPatch);
                        // yay step 1 is already done for us
                        return PreinstallState::ApplyPatch;
                    }
                    // we need to extract non-patched pkg into the cache
                    self.set_preinstall_state(pkg.meta.id, PreinstallState::Extract);
                    return PreinstallState::Extract;
                }

                self.set_preinstall_state(pkg.meta.id, PreinstallState::Extract);

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at src/install/PackageManager/PackageManagerLifecycle.rs:182 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/0981e4b59ee9ebb6. Report an issue: GitHub.