fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error #1138

Merged
HumanBean merged 1 commit from TrashPanda/Longshot:fix/setup-rename-retry into main 2026-11-16 22:07:09 +00:00
Contributor

Type: fix · Risk: low · Tested on: Linux, RTX 4070 Ti (game-free checks) · Needs: Windows

Why

On Windows the setup can stop at "Could not set up part 8 of 8 (renaming llvm-mingw-...)" every time, even as administrator: right after tar.exe unpacks hundreds of .exe and .dll files, an antivirus scan or the search indexer still holds one open, and the one rename the setup tries fails. The message did not say why.

Restored from Hookshot 3021, by jarynclouatre, and split out of #286 so it can be reviewed and merged on its own.

How to reproduce

Seen on: Windows 10/11 with an antivirus that scans new files (reported on Hookshot)
Settings and switches: defaults
Steps: run the setup on a fresh folder while the scanner is busy with the unpacked tools
Expected: the tools are moved into place
Actual: "Could not set up part 8 of 8 (renaming ...)", with no Windows error

What changed

The setup tries a rename that Windows refused with access denied (5) or a sharing violation (32) again every 250 ms for up to 20 s, and its message carries Windows' error and names the folder to allow in the scanner.

Commits, each with its original author and message:

d7b4dceb fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error (jarynclouatre)

The Windows setup unpacks each part with tar.exe and then renames the
folder (llvm-mingw--ucrt-x86_64 to llvm-mingw). Right after
tar.exe writes hundreds of .exe and .dll files, an antivirus scan or the
search indexer can still hold one of them open, and MoveFileW on the
folder then fails with access denied (5) or a sharing violation (32).
The setup tried once and said only "Could not set up part 8 of 8
(renaming llvm-mingw-...)", with no Windows error, which matches https://github.com/NotRexed/Hookshot/pull/3011
(every run, also as administrator).

  • move_retry in setup.c tries those two errors again every 250 ms for
    up to 20 s; any other error returns at once, and GetLastError is the
    last try's. It is used for the part's rename and for both moves of the
    staged install into place in publish_install (not the backup moves).
  • The rename's message now carries Windows' error, and for 5 or 32 says
    another program is holding the unpacked files, often an antivirus scan,
    and names the folder to allow. "Could not finish installing" carries the
    error too.
  • The Python setup (setup_parts.py) does the same on Windows with
    replace_retry at both os.replace calls of install(); on other
    systems a PermissionError is raised at once as before. Its messages
    carry the error text.
  • test_portable_setup_transaction.py cuts move_retry out with
    publish_install and defines Sleep away, so its denied-move case does
    not wait 20 s.

I cannot say which program holds the folder on the reporter's PC; if the
retry is not enough, the next report will carry the error number.

For https://github.com/NotRexed/Hookshot/pull/3011

  • tests/test_setup_rename_retry.py (new): cuts move_retry out of
    setup.c and runs it with its own MoveFileW and Sleep, on Linux with gcc:
    free, denied 3 times then free (4 calls, 3 waits), sharing violation
    twice then free, path not found (1 call, no wait, error 3 kept), denied
    for ever (80 calls, 79 waits, error 5). Fails on main (no move_retry).
  • tests/test_setup_parts_rename_retry.py (new): replace_retry with
    os.replace and time.sleep mocked: two PermissionErrors then free,
    FileNotFoundError at once, PermissionError for ever (80 tries), not
    Windows at once, and install() uses it at both places. Fails on main.
  • python -I -B tests/run_all.py on Linux: 445 passed, 85 skipped, 1
    failed (test_bake_portability.py: zstandard is not installed here).
  • Not run: the Windows-only test_portable_setup_transaction.py and
    test_setup_runtime_paths.py (CI runs them), and a real setup on a PC
    whose scanner holds the folder.

Ported to Longshot: Longshot has no Python setup any more (#171), so setup_parts.py and its test are left out. The tool is
now moved into place by place_tool (Longshot), so move_retry is its whole-folder move, the scanner message is the
tool's, and test_setup_tool_merge.py cuts move_retry out with place_tool.

Restored-from: https://github.com/NotRexed/Hookshot/pull/3021

Measurements

Verdict: nothing to measure: a correctness fix off the frame path, covered by game-free checks.

Flags and settings

None.

Testing

Tested: On Linux (kernel 7.0), RTX 4070 Ti, main @ 71b1edd8, this PR @ d7b4dceb: tests/test_setup_rename_retry.py, tests/test_setup_tool_merge.py pass. tests/test_portable_setup_transaction.py builds with -municode and needs llvm-mingw: it fails the same on main here (no Windows compiler), so it is left to CI. The full suite (tests/run_all.py) has not been run on this branch yet; a comment will follow when it has.

Not tested: A real setup on a PC whose scanner holds the folder (I am on Linux). Opened as work in progress until it runs in the game.

Must be tested:

  • Windows, any GPU (Test Farm: @Beanstalk windows): run the setup into a new folder, expecting it to finish; with a scanner holding the folder, expecting it to wait and then finish, or a message with the Windows error number

Risks

What could break: the setup's moves of the tools into place on Windows.

Turning it off: revert the commit.

Compatibility: Nothing changes.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).

When it applies

  • A game-free test added for the fix, failing on main and passing here.
**Type:** fix · **Risk:** low · **Tested on:** Linux, RTX 4070 Ti (game-free checks) · **Needs:** Windows ## Why On Windows the setup can stop at "Could not set up part 8 of 8 (renaming llvm-mingw-...)" every time, even as administrator: right after tar.exe unpacks hundreds of .exe and .dll files, an antivirus scan or the search indexer still holds one open, and the one rename the setup tries fails. The message did not say why. Restored from [Hookshot 3021](https://github.com/NotRexed/Hookshot/pull/3021), by jarynclouatre, and split out of [#286](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/286) so it can be reviewed and merged on its own. ## How to reproduce **Seen on:** Windows 10/11 with an antivirus that scans new files (reported on Hookshot) **Settings and switches:** defaults **Steps:** run the setup on a fresh folder while the scanner is busy with the unpacked tools **Expected:** the tools are moved into place **Actual:** "Could not set up part 8 of 8 (renaming ...)", with no Windows error ## What changed The setup tries a rename that Windows refused with access denied (5) or a sharing violation (32) again every 250 ms for up to 20 s, and its message carries Windows' error and names the folder to allow in the scanner. Commits, each with its original author and message: <details><summary><code>d7b4dceb</code> fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error (jarynclouatre)</summary> The Windows setup unpacks each part with tar.exe and then renames the folder (llvm-mingw-<version>-ucrt-x86_64 to llvm-mingw). Right after tar.exe writes hundreds of .exe and .dll files, an antivirus scan or the search indexer can still hold one of them open, and MoveFileW on the folder then fails with access denied (5) or a sharing violation (32). The setup tried once and said only "Could not set up part 8 of 8 (renaming llvm-mingw-...)", with no Windows error, which matches https://github.com/NotRexed/Hookshot/pull/3011 (every run, also as administrator). - `move_retry` in setup.c tries those two errors again every 250 ms for up to 20 s; any other error returns at once, and GetLastError is the last try's. It is used for the part's rename and for both moves of the staged install into place in `publish_install` (not the backup moves). - The rename's message now carries Windows' error, and for 5 or 32 says another program is holding the unpacked files, often an antivirus scan, and names the folder to allow. "Could not finish installing" carries the error too. - The Python setup (`setup_parts.py`) does the same on Windows with `replace_retry` at both `os.replace` calls of `install()`; on other systems a PermissionError is raised at once as before. Its messages carry the error text. - `test_portable_setup_transaction.py` cuts `move_retry` out with `publish_install` and defines Sleep away, so its denied-move case does not wait 20 s. I cannot say which program holds the folder on the reporter's PC; if the retry is not enough, the next report will carry the error number. For https://github.com/NotRexed/Hookshot/pull/3011 - `tests/test_setup_rename_retry.py` (new): cuts `move_retry` out of setup.c and runs it with its own MoveFileW and Sleep, on Linux with gcc: free, denied 3 times then free (4 calls, 3 waits), sharing violation twice then free, path not found (1 call, no wait, error 3 kept), denied for ever (80 calls, 79 waits, error 5). Fails on main (no `move_retry`). - `tests/test_setup_parts_rename_retry.py` (new): `replace_retry` with os.replace and time.sleep mocked: two PermissionErrors then free, FileNotFoundError at once, PermissionError for ever (80 tries), not Windows at once, and `install()` uses it at both places. Fails on main. - `python -I -B tests/run_all.py` on Linux: 445 passed, 85 skipped, 1 failed (`test_bake_portability.py`: zstandard is not installed here). - Not run: the Windows-only `test_portable_setup_transaction.py` and `test_setup_runtime_paths.py` (CI runs them), and a real setup on a PC whose scanner holds the folder. Ported to Longshot: Longshot has no Python setup any more (#171), so setup_parts.py and its test are left out. The tool is now moved into place by place_tool (Longshot), so move_retry is its whole-folder move, the scanner message is the tool's, and test_setup_tool_merge.py cuts move_retry out with place_tool. Restored-from: https://github.com/NotRexed/Hookshot/pull/3021 </details> ## Measurements **Verdict:** nothing to measure: a correctness fix off the frame path, covered by game-free checks. ### Flags and settings None. ## Testing **Tested:** On Linux (kernel 7.0), RTX 4070 Ti, `main` @ 71b1edd8, this PR @ d7b4dceb: `tests/test_setup_rename_retry.py`, `tests/test_setup_tool_merge.py` pass. `tests/test_portable_setup_transaction.py` builds with `-municode` and needs llvm-mingw: it fails the same on `main` here (no Windows compiler), so it is left to CI. The full suite (`tests/run_all.py`) has not been run on this branch yet; a comment will follow when it has. **Not tested:** A real setup on a PC whose scanner holds the folder (I am on Linux). Opened as work in progress until it runs in the game. **Must be tested:** - Windows, any GPU (Test Farm: @Beanstalk windows): run the setup into a new folder, expecting it to finish; with a scanner holding the folder, expecting it to wait and then finish, or a message with the Windows error number ## Risks **What could break:** the setup's moves of the tools into place on Windows. **Turning it off:** revert the commit. **Compatibility:** Nothing changes. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). ### When it applies - [x] A game-free test added for the fix, failing on `main` and passing here.
fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
Third-party parts / As their notes say (pull_request) Successful in 8s
PR description / Description follows the template (pull_request_target) Failing after 4s
Third-party parts / The same as upstream (pull_request) Has been skipped
d7b4dcebba
The Windows setup unpacks each part with tar.exe and then renames the
folder (llvm-mingw-<version>-ucrt-x86_64 to llvm-mingw). Right after
tar.exe writes hundreds of .exe and .dll files, an antivirus scan or the
search indexer can still hold one of them open, and MoveFileW on the
folder then fails with access denied (5) or a sharing violation (32).
The setup tried once and said only "Could not set up part 8 of 8
(renaming llvm-mingw-...)", with no Windows error, which matches https://github.com/NotRexed/Hookshot/pull/3011
(every run, also as administrator).

- `move_retry` in setup.c tries those two errors again every 250 ms for
up to 20 s; any other error returns at once, and GetLastError is the
last try's. It is used for the part's rename and for both moves of the
staged install into place in `publish_install` (not the backup moves).
- The rename's message now carries Windows' error, and for 5 or 32 says
another program is holding the unpacked files, often an antivirus scan,
and names the folder to allow. "Could not finish installing" carries the
error too.
- The Python setup (`setup_parts.py`) does the same on Windows with
`replace_retry` at both `os.replace` calls of `install()`; on other
systems a PermissionError is raised at once as before. Its messages
carry the error text.
- `test_portable_setup_transaction.py` cuts `move_retry` out with
`publish_install` and defines Sleep away, so its denied-move case does
not wait 20 s.

I cannot say which program holds the folder on the reporter's PC; if the
retry is not enough, the next report will carry the error number.

For https://github.com/NotRexed/Hookshot/pull/3011

- `tests/test_setup_rename_retry.py` (new): cuts `move_retry` out of
setup.c and runs it with its own MoveFileW and Sleep, on Linux with gcc:
free, denied 3 times then free (4 calls, 3 waits), sharing violation
twice then free, path not found (1 call, no wait, error 3 kept), denied
for ever (80 calls, 79 waits, error 5). Fails on main (no `move_retry`).
- `tests/test_setup_parts_rename_retry.py` (new): `replace_retry` with
os.replace and time.sleep mocked: two PermissionErrors then free,
FileNotFoundError at once, PermissionError for ever (80 tries), not
Windows at once, and `install()` uses it at both places. Fails on main.
- `python -I -B tests/run_all.py` on Linux: 445 passed, 85 skipped, 1
failed (`test_bake_portability.py`: zstandard is not installed here).
- Not run: the Windows-only `test_portable_setup_transaction.py` and
`test_setup_runtime_paths.py` (CI runs them), and a real setup on a PC
whose scanner holds the folder.

Ported to Longshot: Longshot has no Python setup any more (#171), so setup_parts.py and its test are left out. The tool is
now moved into place by place_tool (Longshot), so move_retry is its whole-folder move, the scanner message is the
tool's, and test_setup_tool_merge.py cuts move_retry out with place_tool.

Restored-from: https://github.com/NotRexed/Hookshot/pull/3021
HumanBean changed title from WIP: fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error to fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error 2026-11-16 22:07:04 +00:00
HumanBean deleted branch fix/setup-rename-retry 2026-11-16 22:07:10 +00:00
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
Third-party parts / As their notes say (pull_request) Successful in 8s
PR description / Description follows the template (pull_request_target) Failing after 4s
Third-party parts / The same as upstream (pull_request) Has been skipped
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1138
No description provided.