From 60aa78e18426b45fabffe577805b5f2a048c5c62 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Mon, 18 Nov 2019 20:20:03 +1100 Subject: [PATCH] Ignore file lock errors if unsupported, on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all file systems support file locking; WSL’s network file system doesn’t seem to, and I don’t think other network file systems will, either (though I haven’t checked them). ERROR_INVALID_FUNCTION is Windows’ equivalent to Unix’s ENOTSUP and Linux’s ENOSYS which are checked just above. Fixes #7511. --- src/cargo/util/flock.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index d5cb66fcbcd..aa9cbec27f3 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -7,6 +7,8 @@ use fs2::{lock_contended_error, FileExt}; #[allow(unused_imports)] use libc; use termcolor::Color::Cyan; +#[cfg(windows)] +use winapi::shared::winerror::ERROR_INVALID_FUNCTION; use crate::util::errors::{CargoResult, CargoResultExt}; use crate::util::paths; @@ -311,6 +313,9 @@ fn acquire( #[cfg(target_os = "linux")] Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => return Ok(()), + #[cfg(windows)] + Err(ref e) if e.raw_os_error() == Some(ERROR_INVALID_FUNCTION as i32) => return Ok(()), + Err(e) => { if e.raw_os_error() != lock_contended_error().raw_os_error() { let e = failure::Error::from(e);