From 5ad93127b6337e3ffbccdb38240def225a96aa0e Mon Sep 17 00:00:00 2001 From: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:02:29 +0100 Subject: [PATCH] fix: attempt copying trampoline when hard-linking fails (#2464) Fixes #2462 --- src/global/trampoline.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/global/trampoline.rs b/src/global/trampoline.rs index d9ea13ab6..9055f324c 100644 --- a/src/global/trampoline.rs +++ b/src/global/trampoline.rs @@ -354,9 +354,15 @@ impl Trampoline { .into_diagnostic()?; } - // Create a hard link to the shared trampoline binary - if !self.path().exists() { - tokio::fs::hard_link(self.trampoline_path(), self.path()) + // If the path doesn't exist yet, create a hard link to the shared trampoline binary + // If creating a hard link doesn't succeed, try copying + // Hard-linking might for example fail because the file-system enforces a maximum number of hard-links per file + if !self.path().exists() + && tokio_fs::hard_link(self.trampoline_path(), self.path()) + .await + .is_err() + { + tokio_fs::copy(self.trampoline_path(), self.path()) .await .into_diagnostic()?; }