Running into issues compiling rust projects, on Ubuntu 22.04, with rustc 1.65.
The problem happens with the simplest hello world project, e.g.:
$ cargo new hello $ cd hello $ cargo run Compiling hello v0.1.0 (/tmp/hello) Finished dev [unoptimized + debuginfo] target(s) in 0.29s Running `target/debug/hello` error: could not execute process `target/debug/hello` (never executed) Caused by: No such file or directory (os error 2)
hello, expected to be under
./target/debug/hello is not there. Only
hello.d is there.
I have tried uninstalling and re-installing rust but the problem persists. I installed rust with rustup (i.e.:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh).
In case that can help, doing the following will work. Run a docker container, and mount the host
.cargo directory and the
~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu directory (
rustc --print sysroot).
$ docker run --rm -it -v ~/.cargo:/.cargo -e CARGO_HOME=/.cargo -v `rustc --print sysroot`:/rust:ro -e PATH=$PATH:/rust/bin ubuntu:22.04 bash
In the container, install
gcc and create the toy project, and run it.
apt update && apt install -y gcc cargo new hello cd hello cargo run Compiling hello v0.1.0 (/hello) Finished dev [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/hello` Hello, world!
Another thing I tried:
- Deleted the
- Kept the
- Prepended the PATH with
$ which rustc ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc
$ which cargo ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
But it makes no difference, same problem.