Skip to content

Compiling without correct target generates confusing tuple variant error messages #117640

Closed
@schneems

Description

@schneems

Similar to #65386, I hit a bunch of errors when compiling a project on a new machine. It turns out it was due to the target not being added to rustup, however, that information was somewhat hidden. Details below.

Expected

If core cannot be found that this would halt compilation or that this suggestion would be found at the bottom of the compilation:

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

Actual

When I compiled code I hit a flood of these error messages:

error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
    --> /Users/rschneeman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.190/src/lib.rs:285:32
     |
285  |             Err(err) => return Err(err),
     |                                ^^^ help: a local variable with a similar name exists: `err`****

And

error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
   --> /Users/rschneeman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.190/src/private/ser.rs:989:13
    |
989 |             Ok(Content::StructVariant(
    |             ^^ not found in this scope

And

error[E0425]: cannot find function, tuple struct or tuple variant `Some` in this scope
   --> /Users/rschneeman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.190/src/private/ser.rs:904:24
    |
904 |             self.key = Some(key);
    |                        ^^^^ not found in this scope
    |
help: consider importing one of these items
    |
340 +     use crate::__private::de::Content::Some;
    |
340 +     use crate::__private::ser::Content::Some;

I'm talking hundreds upon hundreds of lines of errors. They pushed the relevant warning which was at the top WAYYY far off screen:

$ time cargo test -- --ignored
   Compiling cfg-if v1.0.0
   Compiling memchr v2.6.4
   Compiling regex-syntax v0.8.2
   Compiling libc v0.2.149
   Compiling equivalent v1.0.1
   Compiling itoa v1.0.9
   Compiling ryu v1.0.15
   Compiling hashbrown v0.14.2
   Compiling bit-vec v0.6.3
   Compiling serde v1.0.190
   Compiling thiserror v1.0.50
   Compiling fnv v1.0.7
   Compiling lazy_static v1.4.0
   Compiling winnow v0.5.17
   Compiling camino v1.1.6
   Compiling semver v1.0.20
   Compiling cargo-platform v0.1.4
   Compiling bit-set v0.5.3
   Compiling serde_json v1.0.107
   Compiling log v0.4.20
   Compiling aho-corasick v1.1.2
   Compiling fancy-regex v0.11.0
   Compiling typenum v1.17.0
   Compiling crossbeam-utils v0.8.16
   Compiling indexmap v2.0.2
   Compiling once_cell v1.18.0
   Compiling tinyvec_macros v0.1.1
   Compiling getrandom v0.2.10
   Compiling either v1.9.0
   Compiling untrusted v0.9.0
   Compiling tinyvec v1.6.0
   Compiling ring v0.17.5
   Compiling errno v0.3.5
   Compiling memoffset v0.9.0
   Compiling uriparse v0.6.4
   Compiling scopeguard v1.2.0
   Compiling bitflags v2.4.1
   Compiling crossbeam-epoch v0.9.15
   Compiling cargo_metadata v0.18.1
   Compiling generic-array v0.14.7
   Compiling rustix v0.38.21
   Compiling percent-encoding v2.3.0
   Compiling regex-automata v0.4.3
   Compiling unicode-normalization v0.1.22
   Compiling adler v1.0.2
   Compiling same-file v1.0.6
   Compiling unicode-bidi v0.3.13
   Compiling walkdir v2.4.0
   Compiling miniz_oxide v0.7.1
   Compiling idna v0.4.0
   Compiling rustls-webpki v0.101.7
   Compiling sct v0.7.1
   Compiling toml_datetime v0.6.5
   Compiling serde_spanned v0.6.4
   Compiling crypto-common v0.1.6
   Compiling toml_edit v0.20.7
   Compiling libcnb-proc-macros v0.15.0
   Compiling block-buffer v0.10.4
   Compiling form_urlencoded v1.2.0
   Compiling libz-sys v1.1.12
   Compiling crossbeam-deque v0.8.3
   Compiling crc32fast v1.3.2
   Compiling strsim v0.10.0
   Compiling url v2.4.1
   Compiling digest v0.10.7
   Compiling rayon-core v1.12.0
   Compiling flate2 v1.0.28
   Compiling num-traits v0.2.17
   Compiling rustls v0.21.8
   Compiling xattr v1.0.1
   Compiling cpufeatures v0.2.11
   Compiling filetime v0.2.22
   Compiling fastrand v2.0.1
   Compiling webpki-roots v0.25.2
   Compiling base64 v0.21.5
   Compiling tar v0.4.40
   Compiling rayon v1.8.0
   Compiling regex v1.10.2
   Compiling ordered-float v3.9.2
   Compiling tempfile v3.8.1
   Compiling sha2 v0.10.8
   Compiling itertools v0.10.5
   Compiling utf8-width v0.1.6
   Compiling is_executable v1.0.1
   Compiling fs_extra v1.3.0
   Compiling pathdiff v0.2.1
   Compiling termcolor v1.3.0
   Compiling byte-unit v4.0.19
   Compiling toml v0.8.6
   Compiling ascii_table v4.0.3
   Compiling const_format v0.2.32
   Compiling bstr v1.7.0
   Compiling libcnb-common v0.15.0
   Compiling libcnb-data v0.15.0
   Compiling ureq v2.8.0
   Compiling fs-err v2.9.0
   Compiling glob v0.3.1
   Compiling utf8parse v0.2.1
   Compiling globset v0.4.13
   Compiling anstyle-parse v0.2.2
   Compiling which_problem v0.1.0
   Compiling thread_local v1.1.7
   Compiling libcnb v0.15.0
   Compiling fixedbitset v0.4.2
   Compiling colorchoice v1.0.0
   Compiling anstyle v1.0.4
   Compiling home v0.5.5
   Compiling anstyle-query v1.0.0
   Compiling libherokubuildpack v0.15.0
   Compiling anstream v0.6.4
   Compiling which v4.4.2
   Compiling petgraph v0.6.4
   Compiling commons v0.1.0 (/Users/rschneeman/Documents/projects/work/buildpacks-ruby/commons)
   Compiling ignore v0.4.20
   Compiling rand_core v0.6.4
   Compiling ppv-lite86 v0.2.17
   Compiling clap_lex v0.6.0
   Compiling clap_builder v4.4.7
   Compiling rand_chacha v0.3.1
   Compiling yansi v0.5.1
   Compiling diff v0.1.13
   Compiling rand v0.8.5
   Compiling pretty_assertions v1.4.0
   Compiling libcnb-package v0.15.0
   Compiling libcnb-test v0.15.0
   Compiling clap v4.4.7
   Compiling heroku-ruby-buildpack v0.0.0 (/Users/rschneeman/Documents/projects/work/buildpacks-ruby/buildpacks/ruby)
    Finished test [unoptimized + debuginfo] target(s) in 8.18s
     Running unittests src/lib.rs (target/debug/deps/commons-9a38f79da319a956)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 43 filtered out; finished in 0.00s

     Running unittests bin/print_style_guide.rs (target/debug/deps/print_style_guide-fc061d2955a70184)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/bin/agentmon_loop.rs (target/debug/deps/agentmon_loop-b1bfed39af47c68c)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in 0.00s

     Running unittests src/main.rs (target/debug/deps/heroku_ruby_buildpack-de1a509d6ef46225)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 14 filtered out; finished in 0.00s

     Running unittests src/bin/launch_daemon.rs (target/debug/deps/launch_daemon-9d926a60aab513a0)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/integration_test.rs (target/debug/deps/integration_test-2b4b4ea36e8963d9)

running 4 tests
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on build directory
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling cfg-if v1.0.0
   Compiling libc v0.2.149
   Compiling autocfg v1.1.0
   Compiling serde v1.0.190
   Compiling thiserror v1.0.50
   Compiling version_check v0.9.4
   Compiling crossbeam-utils v0.8.16
   Compiling typenum v1.17.0
    Blocking waiting for file lock on package cacheerde(build.rs), cfg-if, libc(build.rs), serde(build.rs), typenum(build.rs), unicode-ident, lib...
    Blocking waiting for file lock on build directory
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`

error[E0463]: can't find crate for `compiler_builtins`

For more information about this error, try `rustc --explain E0463`.
    Blocking waiting for file lock on build directoryde(build.rs), cfg-if, libc(build.rs), serde(build.rs), typenum(build.rs), unicode-ident, lib...
error: could not compile `cfg-if` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
test test_barnes_app ... FAILED
   Compiling proc-macro2 v1.0.69
   Compiling cfg-if v1.0.0
   Compiling libc v0.2.149
   Compiling serde v1.0.190
   Compiling memchr v2.6.4
   Compiling memoffset v0.9.0
   Compiling crossbeam-utils v0.8.16
   Compiling typenum v1.17.0
   Compiling generic-array v0.14.7
   Compiling camino v1.1.6
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`

#
# ....
# A ton of errors here

Which contains the correct suggestion, but it's very well hidden in the output. Weirdly it looked like a lot of dependencies compiled correctly, and tests ran (even though they reported 0 results). Then 193 lines down it gives the correct suggestion

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: aarch64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions