rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.67k stars 12.75k forks source link

fs::read_to_string(config.src.join("src/ci/channel")) failed with No such file or directory (os error 2) #128233

Closed rautyrauty closed 3 months ago

rautyrauty commented 3 months ago

After upgrading from 1.79.0 to 1.80.0, a build error appeared.

$ cat src/ci/channel 
stable
$ cat config.toml
change-id = 123711
[build]
cargo = "/usr/bin/cargo"
rustc = "/usr/bin/rustc"
python = "python3"
submodules = false
docs = true
verbose = 2
vendor = true
extended = true
optimized-compiler-builtins = false
tools = ["cargo", "rust-analyzer", "clippy", "rustfmt", "src"]
build-stage = 2
test-stage = 2
doc-stage = 2

[install]
prefix = "/usr"

[rust]
channel = "stable"
codegen-tests = false
backtrace = true
jemalloc = false
rpath = false
debug = false
deny-warnings = false
debuginfo-level = 0
codegen-units = 2

[llvm]
ninja = true
use-libcxx = false
link-shared = true

[target.x86_64-unknown-linux-gnu]
cc = "clang"
cxx = "clang++"
ar = "llvm-ar"
ranlib = "llvm-ranlib"
llvm-config = "/usr/bin/llvm-config"
profiler = "/usr/lib/llvm-17.0/lib64/clang/17/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a"
last lines of $ RUST_BACKTRACE=full python3 x.py build
Running `BUILD_TRIPLE=x86_64-unknown-linux-gnu CARGO=/usr/bin/cargo CARGO_BIN_NAME=rustc CARGO_CRATE_NAME=rustc CARGO_MANIFEST_DIR=/usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=bootstrap CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 CARGO_RUSTC_CURRENT_DIR=/usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap LD_LIBRARY_PATH='/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps:' OUT_DIR=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/build/bootstrap-25d755448802c3d7/out /usr/bin/rustc --crate-name rustc --edition=2021 src/bin/rustc.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=210 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=1 -C metadata=eaa415117dccccfb -C extra-filename=-eaa415117dccccfb --out-dir /usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps -C incremental=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/incremental -L dependency=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps --extern bootstrap=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libbootstrap-46f696eaae99ee0c.rlib --extern build_helper=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libbuild_helper-975f7f68a9a1f9cd.rlib --extern cc=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libcc-79ec9f1a39d6f69b.rlib --extern clap=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libclap-70e7474fe7b03df4.rlib --extern clap_complete=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libclap_complete-11a0a702d7d5500d.rlib --extern cmake=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libcmake-d6bda6b00df510fa.rlib --extern fd_lock=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libfd_lock-fae85a3868928121.rlib --extern filetime=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libfiletime-43a8f27e2a27b3ba.rlib --extern home=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libhome-f1d457c6dfd1f32e.rlib --extern ignore=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libignore-8543ddbbf4e54f77.rlib --extern libc=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/liblibc-b6bc4effb7d345f9.rlib --extern object=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libobject-fb47a8754b36152c.rlib --extern once_cell=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libonce_cell-b2b3a9a17f46244d.rlib --extern opener=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libopener-7280ccb79064e817.rlib --extern semver=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libsemver-cf5c9aee1a824c1a.rlib --extern serde=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libserde-5d592bc2c33eab9f.rlib --extern serde_derive=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libserde_derive-fd6dc4e6c83edd12.so --extern serde_json=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libserde_json-821d274085420d08.rlib --extern sha2=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libsha2-f6e5e5c0d83e84fc.rlib --extern tar=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libtar-5c1958b39d18a88d.rlib --extern termcolor=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libtermcolor-53c2c89867447115.rlib --extern toml=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libtoml-2177481acb3a511f.rlib --extern walkdir=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libwalkdir-e31a8e992f6b2d4d.rlib --extern xz2=/usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/deps/libxz2-a40242f7f67ecce2.rlib -Zallow-features= -Wrust_2018_idioms -Wunused_lifetimes`
    Finished `dev` profile [unoptimized] target(s) in 19.65s
running: /usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/bootstrap build
thread 'main' panicked at src/core/config/config.rs:1319:28:
fs::read_to_string(config.src.join("src/ci/channel")) failed with No such file or directory (os error 2)
stack backtrace:
   0:     0x55dd0087917a - ::fmt::hc4b17510cb5a99eb
   1:     0x55dd0089e8eb - core::fmt::write::h793eed67197eb2b3
   2:     0x55dd0087528f - std::io::Write::write_fmt::h99d24124c02bff2c
   3:     0x55dd00878f7b - std::sys_common::backtrace::print::h04102bdcc106e07b
   4:     0x55dd008587a2 - std::panicking::default_hook::{{closure}}::h0905d66cb0499081
   5:     0x55dd008584ca - std::panicking::default_hook::h6923cacd32992dcc
   6:     0x55dd00858ab6 - std::panicking::rust_panic_with_hook::h3007d11466ec4c3f
   7:     0x55dd0087a2d6 - std::panicking::begin_panic_handler::{{closure}}::h94a9f6539dc8a7ff
   8:     0x55dd008793c9 - std::sys_common::backtrace::__rust_end_short_backtrace::h566485524fb547cf
   9:     0x55dd00858807 - rust_begin_unwind
  10:     0x55dcffb554f3 - core::panicking::panic_fmt::h0e255467f0860a18
  11:     0x55dcffe0d939 - bootstrap::core::config::config::Config::parse_inner::h04d30d6376859737
                               at /usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap/src/utils/helpers.rs:39:23
  12:     0x55dcffb623cd - bootstrap::core::config::config::Config::parse::h7ac5261190395595
                               at /usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap/src/core/config/config.rs:1219:9
  13:     0x55dcffb5bbf5 - bootstrap::main::h1ae284abf0d0dcfa
                               at /usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap/src/bin/main.rs:24:18
  14:     0x55dcffb57373 - core::ops::function::FnOnce::call_once::h5932fab99747257a
                               at /usr/src/RPM/BUILD/rust-1.79.0/library/core/src/ops/function.rs:250:5
  15:     0x55dcffb5ef86 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb17d8ad3bc1ad64f
                               at /usr/src/RPM/BUILD/rust-1.79.0/library/std/src/sys_common/backtrace.rs:155:18
  16:     0x55dcffb595c9 - std::rt::lang_start::{{closure}}::hdc7175e5aa8450da
                               at /usr/src/RPM/BUILD/rust-1.79.0/library/std/src/rt.rs:159:18
  17:     0x55dd00852375 - std::rt::lang_start_internal::h0c6d0a6ced4f159d
  18:     0x55dcffb595a7 - std::rt::lang_start::h97212972d805ae28
                               at /usr/src/RPM/BUILD/rust-1.79.0/library/std/src/rt.rs:158:17
  19:     0x55dcffb5e5ee - main
  20:     0x7fbb0353ec8c - 
  21:     0x7fbb0353ed45 - __libc_start_main
  22:     0x55dcffb55f41 - _start
  23:                0x0 - 
Traceback (most recent call last):
  File "/usr/src/RPM/BUILD/rust-1.80.0/x.py", line 50, in 
    bootstrap.main()
  File "/usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap/bootstrap.py", line 1191, in main
    bootstrap(args)
  File "/usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap/bootstrap.py", line 1167, in bootstrap
    run(args, env=env, verbose=build.verbose, is_bootstrap=True)
  File "/usr/src/RPM/BUILD/rust-1.80.0/src/bootstrap/bootstrap.py", line 186, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /usr/src/RPM/BUILD/rust-1.80.0/build/bootstrap/debug/bootstrap build

build.log

cp src/ci/channel src/bootstrap/src/ci/channel didn't help. Please tell me how to fix it.

tgross35 commented 3 months ago

Could you add some more context about what you are doing? What crate are you trying to read the file from, or what is your end goal? I suspect it just isn't running from where you expect it, try printing std::env::current_dir() to figure out where it's running from. Or include_str! if you are just trying to read it once. Sorry about that, I missed that you were just running x.py build and thought you were attempting to modify bootstrap.

(FYI if you are working on developing rust-lang things, https://rust-lang.zulipchat.com/ can be a good place to go for help).

dtolnay commented 3 months ago

Mentioning @onur-ozkan, as I'm guessing this would bisect to https://github.com/rust-lang/rust/pull/125181.

onur-ozkan commented 3 months ago

config.src.join("src/ci/channel") should be pointing to $project_root/src/ci/channel and the channel file should be there by default.

Try adding dbg!(config.src.join("src/ci/channel")); right above of https://github.com/rust-lang/rust/blob/a526d7ce45fd2284e0e7c7556ccba2425b9d25e5/src/bootstrap/src/core/config/config.rs#L1319

and run ./x.py build --dry-run.

From my side, everything works as expected:

  ~/downloads/rustc-1.80.0-src  $ ./x.py build --dry-run
Building bootstrap
   Compiling bootstrap v0.0.0 (/home/nimda/downloads/rustc-1.80.0-src/src/bootstrap)
    Finished `dev` profile [unoptimized] target(s) in 3.31s
[src/core/config/config.rs:1319:9] config.src.join("src/ci/channel") = "/home/nimda/downloads/rustc-1.80.0-src/src/ci/channel"
WARNING: you have not made a `config.toml`
HELP: consider running `./x.py setup` or copying `config.example.toml` by running `cp config.example.toml config.toml`
Building stage0 library artifacts (x86_64-unknown-linux-gnu)
Building LLVM for x86_64-unknown-linux-gnu
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
WARNING: no codegen-backends config matched the requested path to build a codegen backend. HELP: add backend to codegen-backends in config.toml.
Building tool rustdoc (stage0 -> stage1, x86_64-unknown-linux-gnu)
WARNING: you have not made a `config.toml`
HELP: consider running `./x.py setup` or copying `config.example.toml` by running `cp config.example.toml config.toml`
NOTE: this message was printed twice to make it more likely to be seen
Build completed successfully in 0:00:03
rautyrauty commented 3 months ago

Thanks everyone. I will continue to deal with this issue on Monday.

rautyrauty commented 3 months ago

My fault. I have not sent src/ci to the build environment for several years, since I do not use CI tools.