-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Bootstrap: Try renaming the file if removing fails #127152
Conversation
r? @onur-ozkan rustbot has assigned @onur-ozkan. Use |
@bors try |
Bootstrap: Try renaming the file if removing fails Second attempt at working around rust-lang#127126 If we can't remove the file, then try renaming it. This will leave the destination path free to use. try-job: x86_64-msvc-ext
☀️ Try build successful - checks-actions |
Try build succeeded but considering the failure is intermittent that's doesn't prove this fixes the issue. Still, it's a good sign. I've just tied up the code a bit so I think this is ready for review. |
AFAIK it's not possible to rename locked files on Windows. |
The file is almost certaibly only locked because it's still being executed. That type of lock allows renames but not deletes (specifically it's locked due to a memory map, not due to |
Incidentally this can be trivially demonstrated on a Windows machine by this program: fn main() {
let exe = std::env::current_exe().unwrap();
std::fs::rename(&exe, "moved.exe").unwrap();
} That is, an application the renames itself while it is running. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with the nit fix
src/bootstrap/src/lib.rs
Outdated
if let Err(e) = fs::remove_file(dst) { | ||
if e.kind() != io::ErrorKind::NotFound { | ||
// workaround for https://github.com/rust-lang/rust/issues/127126 | ||
// if removing the file fails, attempt to rename it instead. | ||
let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)); | ||
let _ = fs::rename(dst, format!("{}-{}", dst.display(), now.as_nanos())); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good use case #[cfg(windows)]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used cfg!(windows)
if that's alright as it's easier to integrate.
@bors r=onur-ozkan rollup |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
Let's make this a higher priority, as it can help alleviating spurious CI failures. @bors p=10 |
Bootstrap: Try renaming the file if removing fails Second attempt at working around rust-lang#127126 If we can't remove the file, then try renaming it. This will leave the destination path free to use. try-job: x86_64-msvc-ext
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#126883 (Parenthesize break values containing leading label) - rust-lang#127136 (Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references) - rust-lang#127146 (Uplift fast rejection to new solver) - rust-lang#127152 (Bootstrap: Try renaming the file if removing fails) - rust-lang#127168 (Use the aligned size for alloca at args/ret when the pass mode is cast) - rust-lang#127203 (Fix import suggestion error when path segment failed not from starting) - rust-lang#127212 (Update books) - rust-lang#127224 (Make `FloatTy` checks exhaustive in pretty print) - rust-lang#127230 (chore: remove duplicate words) - rust-lang#127243 (Add test for adt_const_params) r? `@ghost` `@rustbot` modify labels: rollup
☀️ Test successful - checks-actions |
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#126883 (Parenthesize break values containing leading label) - rust-lang#127136 (Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references) - rust-lang#127146 (Uplift fast rejection to new solver) - rust-lang#127152 (Bootstrap: Try renaming the file if removing fails) - rust-lang#127168 (Use the aligned size for alloca at args/ret when the pass mode is cast) - rust-lang#127203 (Fix import suggestion error when path segment failed not from starting) - rust-lang#127212 (Update books) - rust-lang#127224 (Make `FloatTy` checks exhaustive in pretty print) - rust-lang#127230 (chore: remove duplicate words) - rust-lang#127243 (Add test for adt_const_params) r? `@ghost` `@rustbot` modify labels: rollup
Finished benchmarking commit (49ff390): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (secondary -5.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 696.686s -> 695.727s (-0.14%) |
Second attempt at working around #127126
If we can't remove the file, then try renaming it. This will leave the destination path free to use.
try-job: x86_64-msvc-ext