Windows: file rename -force onto a read-only file fails since TIP 744
Open25a127ccbd1f1e3da8ce7ed058ea7f4f570ece56Created 51 days agoUpdated 51 days ago
Descriptionwiki2026-10-12 11:17:09
On Windows,
file rename -force onto an existing read-only file fails
in 9.1 with "permission denied", and the source is not moved. All 8.6 releases
replace the file, as on Unix.
foreach f {src dst} {close [open $f w]}
file attributes dst -readonly 1
file rename -force src dst
TIP 744 ([5e98a389b8]) replaced the rename of the target to a temporary name in
DoRenameFile() by MoveFileExW(MOVEFILE_REPLACE_EXISTING),
which fails for a read-only target. Test fCmd-9.7 covers this, but it was skipped
everywhere because of the undefined notWine constraint.
Referenced by1
0049270a8bFix [219158]: fCmd-9.4 relied on rename() of a read-only directory succeeding, which POSIX does not require (OpenBSD, macOS 10.5 refuse it). Split it into a writable directory test (no constraints) and read-only directory tests for both behaviours, with a new constraint renameNeedsDirWrite in place of darwin9. Fix [300724b80c]: restore the definition of notWine, lost in [c2dc6753fa] in 2020: since then the 19 tests that use it were skipped everywhere. Remove constraints that tests do not need: unix from fCmd-6.9, 8.1, 8.2, 18.6, 20.2, 21.7.1, 21.8.1 and 22.2, and notWine from fCmd-5.5, 6.16, 6.17, 6.18, 9.5, 9.9, 9.13, 9.14 and 10.4 (checked on Windows and Wine). fCmd-9.7 is temporarily unix-only: since TIP 744, renaming onto a read-only file fails on Windows [25a127ccbd]. check-in2026-10-12 11:11:41
Log in (anonymous is fine) to add a comment.