Skip to content

Commit 6c34b71

Browse files
committed
Remove use of hardlinks to symlinks on macOS.
Fixes #3136.
1 parent e0ffef9 commit 6c34b71

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/utils/utils.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,15 @@ where
293293
}
294294

295295
pub(crate) fn hard_or_symlink_file(src: &Path, dest: &Path) -> Result<()> {
296-
if hardlink_file(src, dest).is_err() {
296+
// Some mac filesystems can do hardlinks to symlinks, some can't.
297+
// See rust-lang/rustup#3136 for why it's better never to use them.
298+
#[cfg(target_os = "macos")]
299+
let force_symlink = fs::symlink_metadata(src)
300+
.map(|m| m.file_type().is_symlink())
301+
.unwrap_or(false);
302+
#[cfg(not(target_os = "macos"))]
303+
let force_symlink = false;
304+
if force_symlink || hardlink_file(src, dest).is_err() {
297305
symlink_file(src, dest)?;
298306
}
299307
Ok(())

0 commit comments

Comments
 (0)