Cargo suddently stopped cross compiling to windows

After the last rustup update, cargo doesn't want to cross compile my projects to different targets, other than the local one.

error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-pc-windows-gnu` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-pc-windows-gnu`

(and 100+ errors follow)

I do have the target x86_64-pc-windows-gnu installed, I even removed it and installed again, and even tried removing and reinstalling rustup with all the things and it didn't help. :frowning:

Same happens when trying to cross-compile to x86_64-apple-darwin.

I'm on Ubuntu 22.04 LTS.

Does anyone else have this problem?
Any other things to try?

Have you made sure that you are using the same channel as you installed the targets on?

What does rustup target list give you?

$ rustup target list
...
x86_64-apple-darwin (installed)
x86_64-apple-ios
x86_64-fortanix-unknown-sgx
x86_64-fuchsia
x86_64-linux-android
x86_64-pc-solaris
x86_64-pc-windows-gnu (installed)
x86_64-pc-windows-msvc
x86_64-sun-solaris
x86_64-unknown-freebsd
x86_64-unknown-illumos
x86_64-unknown-linux-gnu (installed)
x86_64-unknown-linux-gnux32
x86_64-unknown-linux-musl
x86_64-unknown-netbsd
x86_64-unknown-redox

rustup show:

$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/pkolaczk/.rustup

installed targets for active toolchain
--------------------------------------

x86_64-apple-darwin
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.60.0 (7737e0b5c 2022-04-04)

Looks like I had to install toolchains, not targets.
The hint given by cargo about missing target was simply wrong. Maybe this is an idea for cargo diagnostics improvement - is it not possible to detect missing toolchain?

No idea why the toolchains messed up in the first place, when I had everything working before, but definitely after reinstalling everything from scratch I forgot to do:

rustup toolchain install stable-x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-apple-darwin

So running those commands has helped.

2 Likes

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.