Filesystems
Temporary files live beside the destination so both paths are on the same filesystem. Renames across mount points may fail with EXDEV.
Linux and macOS
A local filesystem generally lets a process rename a file while another process has it open. The existing descriptor continues to work. Metadata such as extended attributes and ACLs deserves a separate review when replacing an existing file.
Windows
An open file can prevent replacement depending on the sharing flags used by the reader. If replacing a file fails intermittently, check for an editor, antivirus scanner, or indexer holding it open.
Network mounts and containers
NFS clients may cache directory entries, so clients can disagree briefly about which generation they see. In containers, check the actual mount for the parent directory. A read-only bind mount still wins every argument with the write API.