Cargo can't find Rustc in custom install

⚓ rust    📅 2025-06-15    👤 surdeus    👁️ 3      

surdeus

I'm working on a custom install of Rust, which I need for some reason.
When cargo is in /some/custom/dir/bin/cargo and rustc is in /some/other/dir/bin/rustc, and both are in $PATH and also symbolically linked in /usr/bin (and /usr/bin is also in the $PATH), here is what I get:

  • cargo -V works as expected
  • rustc -vV works as expected

cargo build fails very early with:

   0.005687684s DEBUG main:exec:compile_ws:create_bcx:new:new{path="rustc" wrapper=None workspace_wrapper=None rustup_rustc="/home/me/.cargo/bin/rustc" cache_location=Some("/src/target/.rustc_info.json")}: cargo::util::rustc: failed to read rustc info cache: failed to read `/src/target/.rustc_info.json`
   0.005709197s DEBUG main:exec:compile_ws:create_bcx:new:new{path="rustc" wrapper=None workspace_wrapper=None rustup_rustc="/home/me/.cargo/bin/rustc" cache_location=Some("/src/target/.rustc_info.json")}: cargo::util::rustc: rustc info cache miss
   0.005716204s DEBUG main:exec:compile_ws:create_bcx:new:new{path="rustc" wrapper=None workspace_wrapper=None rustup_rustc="/home/me/.cargo/bin/rustc" cache_location=Some("/src/target/.rustc_info.json")}: cargo::util::rustc: running `rustc -vV`
   0.005862119s DEBUG cargo: exit_with_error; err=CliError { error: Some(could not execute process `rustc -vV` (never executed)

Caused by:
    No such file or directory (os error 2)), exit_code: 101 }
   0.005878424s DEBUG cargo: display_error; err=could not execute process `rustc -vV` (never executed)

Caused by:
    No such file or directory (os error 2)
error: could not execute process `rustc -vV` (never executed)

Caused by:
  No such file or directory (os error 2)

Setting $RUSTC to any other value, absolute or relative, results in the exact same error (with the value of $RUSTC instead of rustc).

I initially thought this was a dynamic linking error, but statically-linked binaries do the exact same thing.

I am now out of ideas, it seems I may not understand how cargo_util::ProcessBuilder works. I'm even starting to doubt my understanding of std::process::Command :zany_face:

Btw, this is Rust 1.84 as packaged by Ubuntu.

1 post - 1 participant

Read full topic

🏷️ rust_feed