diff --git a/otherlibs/stdune/src/fpath.ml b/otherlibs/stdune/src/fpath.ml index c9206c40667..4e3f3ca8fe7 100644 --- a/otherlibs/stdune/src/fpath.ml +++ b/otherlibs/stdune/src/fpath.ml @@ -118,7 +118,13 @@ let win32_unlink fn = Unix.chmod fn 0o666; Unix.unlink fn with - | _ -> raise e) + | _ -> + (* On Windows a virus scanner frequently has a lock on new executables for a short while - just retry *) + let rec retry_loop cnt = + Unix.sleep 1; + (try Unix.unlink fn + with _ -> if cnt>0 then retry_loop (cnt-1) else raise e) + in retry_loop 30) ;; let unlink_exn = if Stdlib.Sys.win32 then win32_unlink else Unix.unlink