Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bun_core/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ new!(pub BUN_INSPECT_PRELOAD: string, "BUN_INSPECT_PRELOAD", {});
new!(pub BUN_INSTALL: string, "BUN_INSTALL", {});
new!(pub BUN_INSTALL_BIN: string, "BUN_INSTALL_BIN", {});
new!(pub BUN_INSTALL_GLOBAL_DIR: string, "BUN_INSTALL_GLOBAL_DIR", {});
// Escape hatch: link hoisted packages serially on the main thread instead of on the thread pool.
new!(pub BUN_INSTALL_SERIAL_HOISTED: boolean, "BUN_INSTALL_SERIAL_HOISTED", { default: false });
// Minimum response `Content-Length` (in bytes) for `bun install` to
// stream a tarball directly into libarchive instead of buffering the
// whole body first. Smaller tarballs stay on the buffered path where
Expand Down Expand Up @@ -277,6 +279,8 @@ pub mod feature_flag {
// Test-only: bypass the stdin isatty gate in `bun update --interactive` so
// tests can drive the multi-select by writing keystrokes to a pipe.
new_feature_flag!(pub BUN_INTERNAL_INTERACTIVE_ASSUME_TTY, "BUN_INTERNAL_INTERACTIVE_ASSUME_TTY", {});
// Test-only: prints "[ParallelHoistedInstall] N tasks" so tests can assert the parallel path ran.
new_feature_flag!(pub BUN_INTERNAL_PARALLEL_HOISTED_MARKER, "BUN_INTERNAL_PARALLEL_HOISTED_MARKER", {});
new_feature_flag!(pub BUN_INTERNAL_SUPPRESS_CRASH_IN_BUN_RUN, "BUN_INTERNAL_SUPPRESS_CRASH_IN_BUN_RUN", {});
new_feature_flag!(pub BUN_INTERNAL_SUPPRESS_CRASH_ON_NAPI_ABORT, "BUN_INTERNAL_SUPPRESS_CRASH_ON_NAPI_ABORT", {});
new_feature_flag!(pub BUN_INTERNAL_SUPPRESS_CRASH_ON_UV_STUB, "BUN_INTERNAL_SUPPRESS_CRASH_ON_UV_STUB", {});
Expand Down
18 changes: 13 additions & 5 deletions src/install/PackageInstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ pub struct PackageInstall<'a> {
pub(crate) patch: Option<Patch>,

pub(crate) node_modules: &'a NodeModulesFolder,
pub lockfile: &'a Lockfile,
/// Needed by `verify()` and by Folder installs; thread-pool workers do neither and pass `None`.
pub lockfile: Option<&'a Lockfile>,
}

#[derive(Clone, Copy)]
Expand Down Expand Up @@ -743,6 +744,11 @@ impl UninstallTask {
// ───────────────────────────── impl PackageInstall ─────────────────────────────

impl<'a> PackageInstall<'a> {
fn lockfile(&self) -> &'a Lockfile {
self.lockfile
.expect("only verify() and Folder installs read the lockfile; workers pass neither")
}

///
fn verify_patch_hash(&mut self, patch: Patch, root_node_modules_dir: &Dir) -> bool {
// hash from the .patch file, to be checked against bun tag
Expand Down Expand Up @@ -804,7 +810,7 @@ impl<'a> PackageInstall<'a> {
return false;
};
strings::eql_long(
repo.resolved.slice(&self.lockfile.buffers.string_bytes),
repo.resolved.slice(&self.lockfile().buffers.string_bytes),
&bun_tag_file.bytes,
true,
)
Expand All @@ -821,7 +827,7 @@ impl<'a> PackageInstall<'a> {
resolution::Tag::Root => self.verify_transitive_symlinked_folder(root_node_modules_dir),
resolution::Tag::Folder => {
if self
.lockfile
.lockfile()
.is_workspace_tree_id(self.node_modules.tree_id)
{
self.verify_package_json_name_and_version(root_node_modules_dir, resolution.tag)
Expand Down Expand Up @@ -1001,7 +1007,9 @@ impl<'a> PackageInstall<'a> {

// lastly, check the name.
package_json_checker.found_name()
== self.package_name.slice(&self.lockfile.buffers.string_bytes)
== self
.package_name
.slice(&self.lockfile().buffers.string_bytes)
}

// ───────────────────────────── install backends ─────────────────────────────
Expand Down Expand Up @@ -2311,7 +2319,7 @@ impl<'a> PackageInstall<'a> {

if resolution_tag == resolution::Tag::Folder
&& !self
.lockfile
.lockfile()
.is_workspace_tree_id(self.node_modules.tree_id)
{
supported_method_to_use = Method::Symlink;
Expand Down
Loading
Loading