File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -539,7 +539,18 @@ fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
539
539
// gory details.
540
540
fs:: copy ( src, dst) . map ( |_| ( ) )
541
541
} else {
542
- fs:: hard_link ( src, dst)
542
+ if cfg ! ( target_os = "macos" ) {
543
+ // This is a work-around for a bug on macos. There seems to be a race condition
544
+ // with APFS when hard-linking binaries. Gatekeeper does not have signing or
545
+ // hash informations stored in kernel when running the process. Therefore killing it.
546
+ // This problem does not appear when copying files as kernel has time to process it.
547
+ // Note that: fs::copy on macos is using CopyOnWrite (syscall fclonefileat) which should be
548
+ // as fast as hardlinking.
549
+ // See https://github.com/rust-lang/cargo/issues/10060 for the details
550
+ fs:: copy ( src, dst) . map ( |_| ( ) )
551
+ } else {
552
+ fs:: hard_link ( src, dst)
553
+ }
543
554
} ;
544
555
link_result
545
556
. or_else ( |err| {
You can’t perform that action at this time.
0 commit comments