-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix build failure in case file doesn't exist #63869
Conversation
e8569ba
to
364f669
Compare
I removed the useless parens I added. |
Could we instead make sure the file is created in that same function? The code that creates it should probably have a |
Added the check (hope it's what you had in mind). |
src/bootstrap/doc.rs
Outdated
@@ -375,6 +376,7 @@ impl Step for Standalone { | |||
up_to_date(&footer, &html) && | |||
up_to_date(&favicon, &html) && | |||
up_to_date(&full_toc, &html) && | |||
version_info.exists() && |
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.
If this is false, something has gone horribly wrong; we should remove this check.
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.
This can be false during the dry run. I think the correct fix would be to not run up_to_date(&version_info, &html)
if builder.config.dry_run
just like up_to_date(&rustdoc, &html)
below.
r=me with last comment fixed and commits squashed into one |
60da4a9
to
7fdb312
Compare
src/bootstrap/doc.rs
Outdated
@@ -353,7 +353,8 @@ impl Step for Standalone { | |||
let version_input = builder.src.join("src/doc/version_info.html.template"); | |||
let version_info = out.join("version_info.html"); | |||
|
|||
if !builder.config.dry_run && !up_to_date(&version_input, &version_info) { | |||
if !builder.config.dry_run && | |||
(!version_info.exists() || !up_to_date(&version_input, &version_info)) { |
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.
This change doesn't have any effect as up_to_date
already checks if the file exists:
Lines 173 to 175 in b7ad3f9
if !dst.exists() { | |
return false; | |
} |
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.
Indeed, the check should be on version_input
. Good catch!
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.
That's not what I meant. Checking version_input
makes even less sense as that file has to exist because it's part of the source code.
Try changing the line:
up_to_date(&version_info, &html) &&
to
(builder.config.dry_run || up_to_date(&version_info, &html)) &&
I think that will fix this issue.
c3eee3a
to
4b340b9
Compare
src/bootstrap/doc.rs
Outdated
@@ -353,7 +353,8 @@ impl Step for Standalone { | |||
let version_input = builder.src.join("src/doc/version_info.html.template"); | |||
let version_info = out.join("version_info.html"); | |||
|
|||
if !builder.config.dry_run && !up_to_date(&version_input, &version_info) { | |||
if (builder.config.dry_run || up_to_date(&version_input, &version_info)) && |
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.
It seems like this is wrong. We shouldn't need to generate this file during dry_run; if there's something that reads from it during dry_run then that should be gated, not the file creation.
I wonder if I shouldn't just go back to my initial fix at this point. 😆 |
I think I've caused some confusion. Anyway what I was trying to suggest was to just do: --- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -375,7 +375,7 @@ impl Step for Standalone {
up_to_date(&footer, &html) &&
up_to_date(&favicon, &html) &&
up_to_date(&full_toc, &html) &&
- up_to_date(&version_info, &html) &&
+ (builder.config.dry_run || up_to_date(&version_info, &html)) &&
(builder.config.dry_run || up_to_date(&rustdoc, &html)) {
continue
} That will avoid the panic but I don't know if it's the best fix because I'm not 100% sure what should and shouldn't be run during the dry run. |
dry run as much as possible shouldn't be creating/reading files -- we can mostly avoid this via helper methods on builder which internally return empty strings and such, but not always, which is why we something see gating on dry_run in various code |
4b340b9
to
a80ab3a
Compare
Ok updated. Sorry about the confusion. |
I presume you've tested that this works? |
Not yet. Just applied your suggestion. I'll try it once I'm done with dayjob. |
r=me if it works |
I confirm: problem fixed. Thanks a lot @Mark-Simulacrum and @ollie27 ! @bors: r=Mark-Simulacrum |
📌 Commit a80ab3a has been approved by |
@@ -375,7 +375,7 @@ impl Step for Standalone { | |||
up_to_date(&footer, &html) && | |||
up_to_date(&favicon, &html) && | |||
up_to_date(&full_toc, &html) && | |||
up_to_date(&version_info, &html) && | |||
(builder.config.dry_run || up_to_date(&version_info, &html)) && | |||
(builder.config.dry_run || up_to_date(&rustdoc, &html)) { |
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.
(builder.config.dry_run || up_to_date(&rustdoc, &html)) { | |
builder.config.dry_run || | |
(up_to_date(&version_info, &html) && up_to_date(&rustdoc, &html)) { |
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.
This hurts rather than aids readability in my eyes.
…acrum Fix build failure in case file doesn't exist It fixes the following issue: ```bash $ ./x.py test src/tools/linkchecker ./build/x86_64-apple-darwin/doc/ --stage 1 Updating only changed submodules Submodules updated in 0.05 seconds Finished dev [unoptimized] target(s) in 0.15s thread 'main' panicked at 'source "/Users/imperio/rust/rust/build/x86_64-apple-darwin/doc/version_info.html" failed to get metadata: No such file or directory (os error 2)', src/build_helper/lib.rs:179:19 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. failed to run: /Users/imperio/rust/rust/build/bootstrap/debug/bootstrap test src/tools/linkchecker ./build/x86_64-apple-darwin/doc/ --stage 1 Build completed unsuccessfully in 0:00:01 ``` If the file doesn't exist, it makes sense anyway to just run the command in order to generate it. r? @Mark-Simulacrum
☀️ Test successful - checks-azure |
It fixes the following issue:
If the file doesn't exist, it makes sense anyway to just run the command in order to generate it.
r? @Mark-Simulacrum