Skip to content
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

rust 1.81.0 fails to build without network access #130099

Closed
jpalus opened this issue Sep 8, 2024 · 23 comments
Closed

rust 1.81.0 fails to build without network access #130099

jpalus opened this issue Sep 8, 2024 · 23 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jpalus
Copy link

jpalus commented Sep 8, 2024

Distribution packages are often built from self contained sources in isolated environment without network access. Contrary to previous releases rust 1.81.0 fails to build without network access although it's not clear to me why exactly. ./x.py dist fails with;

Command cd "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/build/tmp/tarball/rustc/src/image" && RUSTC_BOOTSTRAP="1" "/usr/bin/cargo" "vendor" "--versioned-dirs" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/cargo/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rust-analyzer/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./compiler/rustc_codegen_cranelift/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./compiler/rustc_codegen_gcc/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/bootstrap/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/opt-dist/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/syn-1.0.89/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/cargo-0.60.0/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/serde-1.0.136/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/ripgrep-13.0.0/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/regex-1.5.5/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/clap-3.1.6/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/hyper-0.14.18/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/externs/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/ctfe-stress-5/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/cargo-0.60.0/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/token-stream-stress/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/match-stress/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/tuple-stress/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/diesel-1.4.8/Cargo.toml" "--sync" "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./src/tools/rustc-perf/collector/compile-benchmarks/bitmaps-3.1.0/Cargo.toml" (failure_mode=Exit, stdout_mode=Capture, stderr_mode=Capture) did not execute successfully.
Expected success, got exit status: 101
Created at: src/core/build_steps/dist.rs:1026:27
Executed at: src/core/build_steps/dist.rs:1063:40

STDOUT ----


STDERR ----
Updating crates.io index
warning: spurious network error (3 tries remaining): [6] Could not resolve hostname (Could not resolve host: index.crates.io)
warning: spurious network error (2 tries remaining): [6] Could not resolve hostname (Could not resolve host: index.crates.io)
warning: spurious network error (1 tries remaining): [6] Could not resolve hostname (Could not resolve host: index.crates.io)
error: failed to sync

Caused by:
  failed to load pkg lockfile

Caused by:
  failed to get `serde` as a dependency of package `cargo-platform v0.1.8 (/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/src/tools/cargo/crates/cargo-platform)`

Caused by:
  download of config.json failed

Caused by:
  failed to download from `https://index.crates.io/config.json`

Caused by:
  [6] Could not resolve hostname (Could not resolve host: index.crates.io)

Traceback (most recent call last):
  File "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/./x.py", line 50, in <module>
    bootstrap.main()
  File "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/src/bootstrap/bootstrap.py", line 1191, in main
    bootstrap(args)
  File "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/src/bootstrap/bootstrap.py", line 1167, in bootstrap
    run(args, env=env, verbose=build.verbose, is_bootstrap=True)
  File "/tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/src/bootstrap/bootstrap.py", line 186, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /tmp/B.dlfv1vcs/BUILD/rustc-1.81.0-src/build/bootstrap/debug/bootstrap dist -j 28 --verbose
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 8, 2024
@Noratrieb Noratrieb added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 8, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 8, 2024
@onur-ozkan
Copy link
Member

We vendor dependencies in distribution tarballs, so when you run ./x.py dist, bootstrap executes cargo vendor and that will fail if it cannot connect to crates.io. This isn't new behaviour with version 1.81.0; it has been like this for a while (see the PR that made it possible).

@onur-ozkan onur-ozkan removed regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 8, 2024
@onur-ozkan
Copy link
Member

Dropped the regression label as this isn't a regression from the previous stable.

@onur-ozkan onur-ozkan removed the C-bug Category: This is a bug. label Sep 8, 2024
@jieyouxu jieyouxu added the C-discussion Category: Discussion or questions that doesn't represent real issues. label Sep 8, 2024
@jpalus
Copy link
Author

jpalus commented Sep 8, 2024

bootstrap executes cargo vendor and that will fail if it cannot connect to crates.io

I don't see a single cargo vendor invocation like the one in description throughout entire rust 1.80.1 build that happened just a day before it.

@onur-ozkan
Copy link
Member

I don't see a single cargo vendor invocation like the one in description

image

And that command is generated from here.

entire rust 1.80.1 build that happened just a day before it.

Do you mean x build or x dist?

@jpalus
Copy link
Author

jpalus commented Sep 8, 2024

To be clear x.py dist:

  • when building 1.80.1 does not result in any `cargo vendor*
  • when building 1.81.0 it does

@jpalus
Copy link
Author

jpalus commented Sep 8, 2024

Is it perhaps 1089de4

@onur-ozkan
Copy link
Member

onur-ozkan commented Sep 8, 2024

Is it perhaps 1089de4

It shouldn't be that one.

To be clear x.py dist:

  • when building 1.80.1 does not result in any `cargo vendor*
  • when building 1.81.0 it does

Vendoring should be trigger for both builds if I am not missing anything. Can you tell me how did you get "1.80.1" source code? Did you download it from Github as a zip file ? If so, vendoring can be skipped as the check here will return false in that scenario.

Did you download it from Github as a zip file ?

What I mean is this:
image

@jpalus
Copy link
Author

jpalus commented Sep 8, 2024

Is it perhaps 1089de4

It shouldn't be that one.

I don't know what dry run meant in this context but at least prior to this commit codepath existed that would skip cmd execution.

To be clear x.py dist:

  • when building 1.80.1 does not result in any `cargo vendor*
  • when building 1.81.0 it does

Vendoring should be trigger for both builds if I am not missing anything. Can you tell me how did you get "1.80.1" source code? Did you download it from Github as a zip file ?

Downloaded since forever from https://static.rust-lang.org/dist/rustc-1.81.0-src.tar.xz

@onur-ozkan
Copy link
Member

Are you sure that "cargo vendor" is not being executed? Maybe it's being executed but performing no-op 🤔

@jpalus
Copy link
Author

jpalus commented Sep 8, 2024

Attaching full log file for reference:
log.gz

@weihanglo
Copy link
Member

weihanglo commented Sep 9, 2024

Probably because of this PR #125465? Though I removed the code vendoring training crates, bootstrap still accesses the network.

@onur-ozkan
Copy link
Member

Probably because of this PR #125465? Though I removed the code vendoring training crates, bootstrap still accesses the network.

At which part?

@weihanglo
Copy link
Member

Reverting e24be07 didn't make any difference. Index still got updated. So #125465 seems unrelated.

@weihanglo
Copy link
Member

@weihanglo
Copy link
Member

Just bisected and found 3ef77cc is the bad commit. Changing back to using std::process::Command from BootstrapCommand fixes the behavior. Feels odd.

@onur-ozkan
Copy link
Member

Just bisected and found 3ef77cc is the bad commit. Changing back to using std::process::Command from BootstrapCommand fixes the behavior. Feels odd.

cc @Kobzol

@Kobzol
Copy link
Contributor

Kobzol commented Sep 10, 2024

@weihanglo Could you please post the bootstrap invocation that you used to bisect this?

@weihanglo

This comment was marked as outdated.

@weihanglo
Copy link
Member

Finally got time look into the actual code. Seems like cargo vendor execution failed but old bootstrap code didn't check output.status.success(). Hence both the vendor directory and .cargo/config.toml were empty when disting rustc-src in an air-gapped environment.

The 3ef77cc did nothing wrong. It's a correct fix revealing the silent failure. The follow-up question would be: should x.py dist rustc-src respects existing Cargo [source] replacement? Or should we have a config value for respecting that?

@onur-ozkan
Copy link
Member

There's this PR #130110 which makes the dist vendoring configurable.

@weihanglo
Copy link
Member

There's this PR #130110 which makes the dist vendoring configurable.

While my original proposal was using the --respect-source-config flag in cargo vendor, #130110 looks way better a solution to this. Thank you!

I cannot think of a reason people want to create a self-contained source tarball from a self-contained source tarball. That said, we can always look into that feature when it is requested.

Given above I think #130110 resolves this issue.

@Kobzol
Copy link
Contributor

Kobzol commented Sep 11, 2024

Thanks for investigating this! Good to know that the command refactoring helped find a silent error.

@jpalus
Copy link
Author

jpalus commented Nov 29, 2024

Fixed in 1.83.0.

@jpalus jpalus closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

7 participants