-
Notifications
You must be signed in to change notification settings - Fork 927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to update on Windows: os error 32 (file in use) when trying to rename files #4181
Comments
@heaths It seems to me that you have another instance of Rust (such as |
It's possible, sure, but Azure Pipeline tasks are run sequentially. There's no practical reason this hosted agent would be running parallel processes. Yet, I've dealt with numerous issues where Defender itself would hard lock a file too long asynchronously. This lead to numerous changes in our setup engine - not just retries in some core operations. @hallipr I'm not sure what tracing we could enable on the agents - perhaps ETW, but the necessary trace logs will be huge for this (we could use a ring and make sure to terminate ASAP) - but we could try this. Do you see any reason why anything else using these files would be running? I mean, we do this before our pipeline starts building. |
The workaround I would suggest is using named versions instead of updating in place. E.g. |
I get the same problem calling
|
I dont use an IDE. I use the devcontainer-cli and start nvim inside. There does not run any rust-process (no rust-analyzer) until I open a rs-file. And the bug occures when I open the devcontainer and just call |
Verification
Problem
Lately on Windows, we're getting a lot of failures to install or update via rustup because of a file-in-use problem (OS error 32):
Steps
Files can be in use on Windows for many reasons (see below), which typically occurs when the file doesn't have
FILE_SHARE_DELETE
rights (see https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-createfilew). You could put a file in use explicitly (see code below) and then try runningrustup update
.Hardlock source using cargo script on Windows
Possible Solution(s)
I was the former architect on the new Visual Studio setup engine and spent years before that working on our mostly Windows Installer (MSI)-based installations. Files-in-use was a constant problem for which a limited number of retries was often the only recourse even for files you own that should be deleted. For MSI we often had to watch events via a message handler for specific clues and retry the entire installation.
Sometimes it can just be Defender holding them longer than it should, which seems to increase in frequency on faster systems. I've not looked into the rustup code, but assuming it's more or less a "script" batch of file copies, you could put each - on Windows, anyway - in a limited retry loop with ~500ms retry duration.
Notes
No response
Rustup version
Installed toolchains
OS version
Microsoft Windows Server 2022 version 10.0.20348
The text was updated successfully, but these errors were encountered: