Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple matching crates for lazy_static when trying to compile tracing-core #51

Closed
evanjs opened this issue Nov 24, 2019 · 14 comments
Closed
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@evanjs
Copy link

evanjs commented Nov 24, 2019

Now that #37 has been fixed, I am able to get a little further with compiling my project using crate2nix.

When attempting to build, I encounter an error with multiple matching crates for lazy_static.

rust_tracing-core> error[E0464]: multiple matching crates for `lazy_static`
rust_tracing-core>   --> src/lib.rs:78:1
rust_tracing-core>    |
rust_tracing-core> 78 | extern crate lazy_static;
rust_tracing-core>    | ^^^^^^^^^^^^^^^^^^^^^^^^^
rust_tracing-core>    |
rust_tracing-core>    = note: candidates:
rust_tracing-core>            crate `lazy_static`: /nix/store/jql33z8cm1pssd1m70qd4d0bzb925f1w-rustc-1.37.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblazy_static-e27d2cebc85340fe.rlib
rust_tracing-core>            crate `lazy_static`: /nix/store/jql33z8cm1pssd1m70qd4d0bzb925f1w-rustc-1.37.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblazy_static-1a8d3023d6646c0e.rlib
rust_tracing-core> error[E0463]: can't find crate for `lazy_static`
rust_tracing-core>   --> src/lib.rs:78:1
rust_tracing-core>    |
rust_tracing-core> 78 | extern crate lazy_static;
rust_tracing-core>    | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
rust_tracing-core> error: aborting due to 2 previous errors
rust_tracing-core> For more information about this error, try `rustc --explain E0463`.
builder for '/nix/store/jkggrifvxjq57x215grk7p0khrmvyg1q-rust_tracing-core-0.1.7.drv' failed with exit code 1; last 10 log lines:
  
  error[E0463]: can't find crate for `lazy_static`
    --> src/lib.rs:78:1
     |
  78 | extern crate lazy_static;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
  
  error: aborting due to 2 previous errors

nix-info -m

  • system: "x86_64-linux"
  • host os: Linux 5.3.11, NixOS, 19.09.1300.08e503bac6d (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3
  • channels(root): "nixos-19.09.1300.08e503bac6d"
  • channels(evanjs): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
    crate2nix version: crate2nix 0.6.0 (installed from master)

Happy to provide any other information that might help.

@cpcloud
Copy link
Contributor

cpcloud commented Nov 24, 2019

@kolloch This is the problem I reference in the FIXME here.

@kolloch
Copy link
Collaborator

kolloch commented Nov 24, 2019

Thank you. I could reproduce this problem but have trouble understanding why this happens.

I would expect two flags of similar to --extern lazy_static=/nix/store/d08mk7m3j57kadk1vykjvmdc0sjmsf4d-rust_lazy_static-1.4.0/lib/liblazy_static-28e1bf1896.rlib to be specified when building it. Instead, I do not see any and wonder how it picks up two of them.

@kolloch kolloch added help wanted Extra attention is needed bug Something isn't working labels Nov 24, 2019
@kolloch
Copy link
Collaborator

kolloch commented Nov 24, 2019

Ah, okay, we might need to filter duplicate ones in filterDependencies.

@kolloch
Copy link
Collaborator

kolloch commented Nov 24, 2019

If you have some time, I'd love a minimal reproducible example for this.

I could reproduce this before with the "with_problematic_crates" example when using "tracing" with default features. See #51 (comment)

Now, I cannot reproduce it anymore. Can you?

I'd love a minimal project example which has only a small number of dependencies.

I suspect that my nixpkgs update fixed it.

@evanjs
Copy link
Author

evanjs commented Nov 25, 2019

I was actually able to reproduce by only adding tracing_core an otherwise empty new project.
With ffc06fd, I can't seem to reproduce anymore.

Another error popped up, though...
Seems similar to #4 and #5:

rust_crate2nix> Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=8 --edition 2018 --cfg feature="default" --out-dir target/build/crate2nix-51 --emit=dep-info,link -L dependency=target/buildDeps --cap-lints allow -L native=/nix/store/y2irx4ldvz8c6823skr37rw8ywidwz2a-dbus-1.12.16-lib/lib -l dbus-1 --color always
rust_crate2nix> error[E0432]: unresolved import `dbus_codegen`
rust_crate2nix>  --> build.rs:3:5
rust_crate2nix>   |
rust_crate2nix> 3 | use dbus_codegen;
rust_crate2nix>   |     ^^^^^^^^^^^^ no `dbus_codegen` external crate
rust_crate2nix> error: aborting due to previous error
rust_crate2nix> For more information about this error, try `rustc --explain E0432`.
builder for '/nix/store/7hlx61n1dxgjbimb3hwq9v911li9iw0l-rust_crate2nix-51-0.1.0.drv' failed with exit code 1; last 10 log lines:
  Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=8 --edition 2018 --cfg feature="default" --out-dir target/build/crate2nix-51 --emit=dep-info,link -L dependency=target/buildDeps --cap-lints allow -L native=/nix/store/y2irx4ldvz8c6823skr37rw8ywidwz2a-dbus-1.12.16-lib/lib -l dbus-1 --color always
  error[E0432]: unresolved import `dbus_codegen`
   --> build.rs:3:5
    |
  3 | use dbus_codegen;
    |     ^^^^^^^^^^^^ no `dbus_codegen` external crate
  
  error: aborting due to previous error
  
  For more information about this error, try `rustc --explain E0432`.

I can open another issue for that 😛


In any case, this particular issue with lazy_static and tracing_core seems to be resolved.

@kolloch
Copy link
Collaborator

kolloch commented Nov 25, 2019

Thank you for testing!

I think that noDefaultFeatures/default-features=false is broken and therefore the error case is not triggered anymore. Keeping this open until that is resolved :(

For dbus_codegen, I do not see any extern parameter. Something is quite wrong :( Could you please create another bug with a reproducing repro? I would be appreciated...

@kolloch
Copy link
Collaborator

kolloch commented Nov 27, 2019

So this builds but I think that the dependency with the more specific target should probably override the features of the general dependency. crate2nix will currently merge their feature sets.

@kolloch
Copy link
Collaborator

kolloch commented Mar 16, 2020

Let's reopen if this becomes a concrete problem again.

@kolloch kolloch closed this as completed Mar 16, 2020
@bbigras
Copy link
Contributor

bbigras commented May 28, 2020

I have a similar problem. Tell me if you want me to open a new issue:

Cargo.toml

futures = { version = "0.3", default-features = false, features = ["compat"] }
futures01 = { package = "futures", version = "0.1" }

main.rs

use futures01::future::IntoFuture;

fn something(
) -> impl futures01::Future<Item = (), Error = std::io::Error> {
    Ok(()).into_future()
}

fn main() {
    println!("Hello, world!");
}

log

error[E0465]: multiple rlib candidates for `futures01` found
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^
  |
note: candidate #1: /nix/store/jwjxndqbg3jncs0fp3jdw5gxn06bdwfm-rust_futures-0.3.5-lib/lib/libfutures-a0288b50d7.rlib
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^
note: candidate #2: /nix/store/bikk5jmdrkj84lhwnbvdvld29g7awc8k-rust_futures-0.1.29-lib/lib/libfutures-935dbfd7d6.rlib
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^

error[E0463]: can't find crate for `futures01`
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^ can't find crate

@kolloch
Copy link
Collaborator

kolloch commented May 28, 2020

That looks like this issue.

Do you use nixpks-unstable?

Can you include the rustc command lines?

@bbigras
Copy link
Contributor

bbigras commented May 28, 2020

Do you use nixpks-unstable?

Yes

Can you include the rustc command lines?

Do you mean the full build log like this:

these derivations will be built:
  /nix/store/q6xrcw6srxkdkxpqyd9f1cxzfj6rdj7y-rust_test-crate2nix-0.1.0.drv
  /nix/store/cwrfdph4g7ps653yfgf9mb6n9xdxaynp-all-workspace-members.drv
building '/nix/store/q6xrcw6srxkdkxpqyd9f1cxzfj6rdj7y-rust_test-crate2nix-0.1.0.drv'...
unpacking sources
unpacking source archive /nix/store/d3nqc9v4113kmpkkgj0pbvar7zkvq3c9-source
source root is source
patching sources
configuring
Running cd .
building
Building test-crate2nix (src/main.rs)
Running rustc --crate-name test_crate2nix src/main.rs --crate-type bin -C opt-level=3 -C codegen-units=4 --remap-path-prefix=/build=/ --extern futures01=/nix/store/bikk5jmdrkj84lhwnbvdvld29g7awc8k-rust_futures-0.1.29-lib/lib/libfutures-935dbfd7d6.rlib --extern futures01=/nix/store/jwjxndqbg3jncs0fp3jdw5gxn06bdwfm-rust_futures-0.3.5-lib/lib/libfutures-a0288b50d7.rlib --cfg feature="default" --edition 2018 --out-dir target/bin -L dependency=target/deps --cap-lints allow --color always
error[E0465]: multiple rlib candidates for `futures01` found
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^
  |
note: candidate #1: /nix/store/jwjxndqbg3jncs0fp3jdw5gxn06bdwfm-rust_futures-0.3.5-lib/lib/libfutures-a0288b50d7.rlib
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^
note: candidate #2: /nix/store/bikk5jmdrkj84lhwnbvdvld29g7awc8k-rust_futures-0.1.29-lib/lib/libfutures-935dbfd7d6.rlib
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^

error[E0463]: can't find crate for `futures01`
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0463`.
builder for '/nix/store/q6xrcw6srxkdkxpqyd9f1cxzfj6rdj7y-rust_test-crate2nix-0.1.0.drv' failed with exit code 1
cannot build derivation '/nix/store/cwrfdph4g7ps653yfgf9mb6n9xdxaynp-all-workspace-members.drv': 1 dependencies couldn't be built
error: build of '/nix/store/cwrfdph4g7ps653yfgf9mb6n9xdxaynp-all-workspace-members.drv' failed

@kolloch
Copy link
Collaborator

kolloch commented May 29, 2020

This is an instance of #83.

The generated command line is definitely wrong:

Running rustc --crate-name test_crate2nix src/main.rs --crate-type bin -C opt-level=3 -C codegen-units=4 --remap-path-prefix=/build=/ --extern futures01=/nix/store/bikk5jmdrkj84lhwnbvdvld29g7awc8k-rust_futures-0.1.29-lib/lib/libfutures-935dbfd7d6.rlib --extern futures01=/nix/store/jwjxndqbg3jncs0fp3jdw5gxn06bdwfm-rust_futures-0.3.5-lib/lib/libfutures-a0288b50d7.rlib --cfg feature="default" --edition 2018 --out-dir target/bin -L dependency=target/deps --cap-lints allow --color always

There is a regression test that is very similar, so I suspect you are not using a recent crate2nix (from master) version or not an updated nixpkgs-unstable version. Try updating both. You need this PR.

@bbigras
Copy link
Contributor

bbigras commented May 29, 2020

I should be up-to-date now and I still have the problem:

I don't have to use -n '<nixos-unstable>' right? Since I'm on unstable and I don't have the stable channel.

crate2nix 0.9.0-alpha.1

  • system: "x86_64-linux"
  • host os: Linux 5.4.42, NixOS, 20.09pre227294.46f975f81e0 (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.4
  • channels(bbigras): "home-manager, unstable-20.09pre227294.46f975f81e0"
  • channels(root): "nixos-20.09pre227294.46f975f81e0, nixos-hardware"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
crate2nix generate
nix-build Cargo.nix

[...]

Running rustc --crate-name test_crate2nix src/main.rs --crate-type bin -C opt-level=3 -C codegen-units=4 --remap-path-prefix=/build=/ --extern futures01=/nix/store/psw2biiczndm4jlifxjbjhpiksqsl1fr-rust_futures-0.1.29-lib/lib/libfutures-935dbfd7d6.rlib --extern futures01=/nix/store/lpz991aqha42z48s7hvp1sa4ykss25vv-rust_futures-0.3.5-lib/lib/libfutures-a0288b50d7.rlib --cfg feature="default" --edition 2018 --out-dir target/bin -L dependency=target/deps --cap-lints allow --color always
error[E0465]: multiple rlib candidates for `futures01` found
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^
  |
note: candidate #1: /nix/store/psw2biiczndm4jlifxjbjhpiksqsl1fr-rust_futures-0.1.29-lib/lib/libfutures-935dbfd7d6.rlib
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^
note: candidate #2: /nix/store/lpz991aqha42z48s7hvp1sa4ykss25vv-rust_futures-0.3.5-lib/lib/libfutures-a0288b50d7.rlib
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^

error[E0463]: can't find crate for `futures01`
 --> src/main.rs:1:5
  |
1 | use futures01::future::IntoFuture;
  |     ^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0463`.
builder for '/nix/store/93zgwwc57p5dd9398rpz2i3nmqyb1v4a-rust_test-crate2nix-0.1.0.drv' failed with exit code 1
cannot build derivation '/nix/store/ny4ssg0dnr282rpa1yv2qmpjws9lpafb-all-workspace-members.drv': 1 dependencies couldn't be built
error: build of '/nix/store/ny4ssg0dnr282rpa1yv2qmpjws9lpafb-all-workspace-members.drv' failed

@kolloch
Copy link
Collaborator

kolloch commented May 29, 2020

Sorry, you are right! I didn't push the fix. Sorry for that. It should be pushed now and work for you. Thanks for your insistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants