-
Notifications
You must be signed in to change notification settings - Fork 13.3k
nightly cargo can no longer build anything due to error: failed to create directory ...\target
Caused by: Incorrect function. (os error 1)
#137499
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
nightly cargo can no longer build anything due to error: failed to create directory ...\target
Caused by: Incorrect function. (os error 1)
#137499
Comments
Is this on an imdisk ram drive? |
Happens on real disk (local, SATA, NTFS) but can also repro on SoftPerfect RAM Disk. |
Hm, a usual reason for this error is Failing to create a directory with that error is highly unusual. I can't yet repro it on my machine using the latest nightly. Does it work if you manually create the target directory? |
(SoftPerfect supports canonicalisation, I build crates there all the time; neither here nor there since this also happens on real disks) It does for a bit until it tries to create another:
|
Do you have any security software that might be interfering with the build? |
No, and the nightlies have always worked before (admittedly, I don't build on nightly all that often) and my setup hasn't changed. Is there something I can do to bisect this to some syscall or function call? Maybe a symbol to step through? Blindly attaching gdb and hoping when the compiler isn't even panicking/aborting/whatever seems like a fool's errand. |
You could try cargo-bisect-rustc https://rust-lang.github.io/cargo-bisect-rustc/installation.html To narrow down the nightly that started failing. |
Otherwise there's process monitor to look at the failing function calls https://learn.microsoft.com/en-us/sysinternals/downloads/procmon |
|
Reproed on plain searched nightlies: from nightly-2024-10-01 to nightly-2025-01-27 bisected with cargo-bisect-rustc v0.6.9Host triple: x86_64-pc-windows-gnu cargo bisect-rustc --access=github --start=2024-10-01 --end=2025-01-27 |
Ah most likely https://github.com/rust-lang/rust/pull/131072/files I'll put up a PR tomorrow to hopefully fix this. What's your Windows version btw? |
Certainly smells like it, yeah. Procmon says: those are the only two NOT SUPPORTEDs (sorry for the screenshot but I can't seem to be able to extract something legible from this). Clicking Properties doesn't really show what the operation was supposed to be either? I'm on windows 10. winver says "Microsoft Windows Version 1607 (OS Build 14393.693)". |
Windows: Fix error in `fs::rename` on Windows 1607 Fixes rust-lang#137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc `@bors` r? ghost
@nabijaczleweli would you mind testing the fix using https://github.com/kennytm/rustup-toolchain-install-master to install E.g.:
|
Sorry, no dice:
|
ok i wanted to try to do a rustc with a fully-reverted 00bf74d to see if this would help. but. well. i can't really. build the compiler? due to this. so. maybe i can cross-build lol |
Revert 00bf74d In service of rust-lang#137499 try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
Windows: Fix error in `fs::rename` on Windows 1607 Fixes rust-lang#137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
Ok, I tried to reproduce this on a vanilla 1607 install and it failed, the same as you saw. Then I did a bunch of updates and installed Visual Studio (to test msvc) and now the windows-gnu |
I don't think I've ever installed VS here, just MSYS2.
Could this be something related to the build date directly? Is there, like a manifest of some kind embedded that .... becomes invalid? or stops being parsed correctly? and this .... changes the runtime profile to.... hide the syscalls? nevermind this makes no sense
I'm open to trying any sort of bisection/debugging you can think of, but I can't really think of anything (the win32 domain is not one I'm well-versed in).
|
I used a VM to install 1607 without updates, which repo'd the failure. I then ran updates (KB890830, KB5050109, KB4103720), reset the machine and now it works. So this seems like it might be a bug in the Windows kernel. Which we happened not to hit before for some reason. |
I figure out I messed up
Doing that, my fix does indeed seem to work:
|
omg real. I can repro the fix:
|
Build 14393.693 is (also?) Windows Server 2016. Windows' wonderfully descriptive NT status code to Win32 error code mappings strike again: rust/library/std/src/sys/pal/windows/fs.rs Line 1354 in 0c72c0d
As we already have fallback logic for |
Windows: Fix error in `fs::rename` on Windows 1607 Fixes rust-lang#137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
Windows: Fix error in `fs::rename` on Windows 1607 Fixes rust-lang#137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
Rollup merge of rust-lang#137528 - ChrisDenton:rename-win, r=joboet Windows: Fix error in `fs::rename` on Windows 1607 Fixes rust-lang#137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
|
Windows: Fix error in `fs::rename` on Windows 1607 Fixes rust-lang#137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
The stable version |
Hm, I think updating nightly to 2025-03-12 also updated my rustup and now I'm getting
lol I downloaded the latest https://rustup.rs/ and got the same thing:
I also replaced the rustup.exe under |
Oh no, looks like rustup's last update was built from. You can download the previous version here https://static.rust-lang.org/rustup/archive/1.27.1/x86_64-pc-windows-msvc/rustup-init.exe and then do:
To stop it auto-updating for now. |
That works! and the new stable works too. |
I tried this code:
I expected to see this happen: the crate builds
Instead, this happened:
Happens to every crate any where I put it. I can obviously manually create this. Stable can build these too.
Meta
rustc +nightly --version --verbose
:Stable still works
The text was updated successfully, but these errors were encountered: