Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround copying file returning EAGAIN on ZFS on mac OS #13845

Merged
merged 2 commits into from
May 2, 2024
Merged
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion crates/cargo-util/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,23 @@ fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
// Note that: fs::copy on macos is using CopyOnWrite (syscall fclonefileat) which should be
// as fast as hardlinking.
// See https://github.com/rust-lang/cargo/issues/10060 for the details
fs::copy(src, dst).map(|_| ())
fs::copy(src, dst).map_or_else(
|e| {
if e.raw_os_error()
.map_or(false, |os_err| os_err == 35 /* libc::EAGAIN */)
{
tracing::info!("copy failed {e:?}. falling back to fs::hard_link");

// Working around an issue copying too fast with zfs (probably related to
// https://github.com/openzfsonosx/zfs/issues/809)
// See https://github.com/rust-lang/cargo/issues/13838
fs::hard_link(src, dst)
} else {
Err(e)
}
},
|_| Ok(()),
)
} else {
fs::hard_link(src, dst)
}
Expand Down
Loading