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
15 changes: 13 additions & 2 deletions src/install/PackageInstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2276,8 +2276,19 @@ impl<'a> PackageInstall<'a> {
dest_name_buf[..dest.len()].copy_from_slice(dest);
// SAFETY: zero-initialized; NUL at [dest.len()].
let dest_z = ZStr::from_buf(&dest_name_buf, dest.len());
if let Err(err) = sys::symlinkat(target_z, dest_dir.fd(), dest_z) {
return InstallResult::fail(err.into(), Step::LinkingDependency, None);
if let Err(first_err) = sys::symlinkat(target_z, dest_dir.fd(), dest_z) {
// A stale entry can survive `skip_delete` (a member's
// internal node_modules outlives a root node_modules wipe);
// replace it and retry, like the Windows branch above.
Comment thread
robobun marked this conversation as resolved.
let retry = first_err.get_errno() == sys::E::EEXIST;
let mut result = Err(first_err);
if retry {
self.uninstall_before_install(destination_dir);
result = sys::symlinkat(target_z, dest_dir.fd(), dest_z);
}
if let Err(err) = result {
return InstallResult::fail(err.into(), Step::LinkingDependency, None);
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/install/isolated_install/Installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,16 @@ impl<'a> Installer<'a> {
break 'state (node_id, CompleteState::Skipped);
}

// A member displaced by a root dependency is reachable only
// through non-workspace edges, and workspace store tasks re-run
// every install, so a completed one is not an install.
Comment thread
robobun marked this conversation as resolved.
let pkg_id = nodes.items_pkg_id()[node_id.get() as usize];
if self.lockfile().packages.slice().items_resolution()[pkg_id as usize].tag
== ResolutionTag::Workspace
{
break 'state (node_id, CompleteState::Skipped);
}

break 'state (node_id, state);
};

Expand Down
53 changes: 30 additions & 23 deletions src/install/lockfile/Package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,31 +1750,38 @@ impl Package<u64> {
.append::<String>(if relative.is_empty() { b"." } else { relative });
}
dependency::version::Tag::Npm => {
if let Some(workspace_version) = workspace_version {
let satisfies =
dependency_version
.npm()
.version
.satisfies(workspace_version, buf, buf);
if let Some(wp) = workspace_path {
let satisfies = match workspace_version {
Some(workspace_version) => {
dependency_version
.npm()
.version
.satisfies(workspace_version, buf, buf)
}
// A versionless member is only linkable by a wildcard
// range, matching `get_or_put_resolved_package`.
Comment thread
robobun marked this conversation as resolved.
None => dependency_version.npm().version.is_star(),
};
if pm.options.link_workspace_packages && satisfies {
// `String::sliced` takes `&'a self`; bind the unwrapped
// value so the borrow outlives the parse call.
let wp = workspace_path.unwrap();
let path = wp.sliced(buf);
if let Some(mut dep) = dependency::parse_with_tag(
external_alias.value,
Some(external_alias.hash),
path.slice,
dependency::version::Tag::Workspace,
&path,
Some(&mut *log),
Some(&mut *pm),
) {
// Whole-struct move so `Drop` frees the old npm
// chain; keep the existing `literal`.
dep.literal = dependency_version.literal;
dependency_version = dep;
if workspace_version.is_some() {
let path = wp.sliced(buf);
if let Some(mut dep) = dependency::parse_with_tag(
external_alias.value,
Some(external_alias.hash),
path.slice,
dependency::version::Tag::Workspace,
&path,
Some(&mut *log),
Some(&mut *pm),
) {
// Whole-struct move so `Drop` frees the old npm
// chain; keep the existing `literal`.
Comment thread
robobun marked this conversation as resolved.
dep.literal = dependency_version.literal;
dependency_version = dep;
}
}
// For a versionless member the dependency stays as-is;
// resolution links it to the workspace package.
Comment thread
robobun marked this conversation as resolved.
} else {
// It doesn't satisfy, but a workspace shares the same name. Override the workspace with the other dependency
for dep in &mut package_dependencies[0..dependencies_count as usize] {
Expand Down
Loading