Cannot run cargo anymore: failed to run `rustc` to learn about target-specific information

Hello,

I don't know if it is related, but after deleted ~/.cargo folder, I can no longer compile any rust project.

$ cargo new abc
$ cd abc
$ cargo build
error: failed to run `rustc` to learn about target-specific information

Caused by:
  could not execute process `sccache rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (never executed)

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

Some informations:

  • I am on linux
  • I installed rust via rustup (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh)
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/jonathan/.rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.44.1 (c7087fe00 2020-06-17)

$ rustc -Vv
rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-unknown-linux-gnu
release: 1.44.1
LLVM version: 9.0

I tried uninstalling rustup, remove ~/.rustup and reinstall from scratch, but nothing help. I am stuck.

~/.cargo/bin is where rustup stores its binary shims of cargo, rustc, etc.

It seems like rm -rf ~/.cargo ~/.rustup then reinstalling should fix it, as far as I know rustup should not have any data outside those two directories that would affect it.

Oh, I see sccache in there. Did you use cargo install sccache to install it originally? It would have been in your ~/.cargo/bin as well then. Try removing it from your RUSTFLAGS or wherever you have enabled it. (I'd recommend using your package manager to install it to avoid issues like this).

Thanks @Nemo157. I obviously forgot that I defined an export RUSTC_WRAPPER=sccache in my profile!

Removing the export fixed my problem thanks :slight_smile:

1 Like

I do use package manager to install stuff. Most of the time I use pacman or its wrapper yay. For rust I might use rustup or cargo, but I never install stuff manually, unless I have no other choice.

But In this context, I have to say, I don't remember setting up sccache, nor why I did set it up :thinking:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.