summaryrefslogtreecommitdiff
path: root/cli/npm/managed/resolvers/local.rs
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-11-04 20:16:53 -0800
committerGitHub <noreply@github.com>2024-11-05 04:16:53 +0000
commitf9a05068d6de247574fb764044a446d1d7ed2e9b (patch)
treef11a18b1d373b102184f6bf44a100e637544aa90 /cli/npm/managed/resolvers/local.rs
parent383cb85a730e42a2951ead84233ccef0ed3a23e8 (diff)
fix(install): handle invalid function error, and fallback to junctions regardless of the error (#26730)
Fixes #26116. Handle the new error and treat is as lacking permission to make symlinks, but also to make this more robust, just always fall back to junctions no matter what the actual error is. Instead, warn if the error isn't one we've handled, but go on to attempt creating the junction
Diffstat (limited to 'cli/npm/managed/resolvers/local.rs')
-rw-r--r--cli/npm/managed/resolvers/local.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/cli/npm/managed/resolvers/local.rs b/cli/npm/managed/resolvers/local.rs
index 0968be8a7..eddb0dc9b 100644
--- a/cli/npm/managed/resolvers/local.rs
+++ b/cli/npm/managed/resolvers/local.rs
@@ -1035,12 +1035,18 @@ fn junction_or_symlink_dir(
if symlink_err.kind() == std::io::ErrorKind::PermissionDenied =>
{
USE_JUNCTIONS.store(true, std::sync::atomic::Ordering::Relaxed);
- junction::create(old_path, new_path).map_err(Into::into)
+ junction::create(old_path, new_path)
+ .context("Failed creating junction in node_modules folder")
+ }
+ Err(symlink_err) => {
+ log::warn!(
+ "{} Unexpected error symlinking node_modules: {symlink_err}",
+ colors::yellow("Warning")
+ );
+ USE_JUNCTIONS.store(true, std::sync::atomic::Ordering::Relaxed);
+ junction::create(old_path, new_path)
+ .context("Failed creating junction in node_modules folder")
}
- Err(symlink_err) => Err(
- AnyError::from(symlink_err)
- .context("Failed creating symlink in node_modules folder"),
- ),
}
}