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 rlib candidates for tokio_02 found #297

Open
djmarcin opened this issue Nov 22, 2020 · 5 comments
Open

multiple rlib candidates for tokio_02 found #297

djmarcin opened this issue Nov 22, 2020 · 5 comments

Comments

@djmarcin
Copy link
Contributor

I'm looking into converting a project to use bazel. It depends on tokio 0.3 as well as tokio 0.2 via the tokio_compat_02 library. When compiling tokio_compat_02 this error occurs:

INFO: From Compiling Rust lib tokio_compat_02 v0.1.2 (4 files):
error[E0465]: multiple rlib candidates for `tokio_02` found
  --> external/raze__tokio_compat_02__0_1_2/src/lib.rs:88:5
   |
88 | use tokio_02::runtime::{Handle, Runtime};
   |     ^^^^^^^^
   |
note: candidate #1: /home/vagrant/.cache/bazel/_bazel_vagrant/71ed060a30795ab0736b520a305b19cd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/raze__tokio__0_2_22/libtokio-1162538576.rlib
  --> external/raze__tokio_compat_02__0_1_2/src/lib.rs:88:5
   |
88 | use tokio_02::runtime::{Handle, Runtime};
   |     ^^^^^^^^
note: candidate #2: /home/vagrant/.cache/bazel/_bazel_vagrant/71ed060a30795ab0736b520a305b19cd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/raze__tokio__0_3_3/libtokio--1544283644.rlib
  --> external/raze__tokio_compat_02__0_1_2/src/lib.rs:88:5
   |
88 | use tokio_02::runtime::{Handle, Runtime};
   |     ^^^^^^^^

I've tried manually renaming the target in BUILD.tokio-0.2.22.bazel to tokio_02 as well as all the crates that depend on it, but the same error occurs. I'm not sure where to go from here.

@djmarcin
Copy link
Contributor Author

djmarcin commented Nov 22, 2020

The problem appears to be that the generated BUILD.tokio_compat_02-0.1.2.bazel contains the following:

    aliases = {
        "@raze__tokio__0_2_22//:tokio": "tokio_02",
        "@raze__tokio__0_3_3//:tokio": "tokio_02",
    },

Manually changing this to the folloiwng appears to fix the problem.

    aliases = {
        "@raze__tokio__0_2_22//:tokio": "tokio_02",
        "@raze__tokio__0_3_3//:tokio": "tokio",
    },

It looks like this is generated here, but it's not clear to me how to override these.

aliases = {
{%- for alias in crate.default_deps.aliased_dependencies %}
"{{alias.target}}": "{{alias.alias}}",
{%- endfor %}
{%- for dep in crate.targeted_deps %}
{%- for alias in dep.deps.aliased_dependencies %}
"{{alias.target}}": "{{alias.alias}}",
{%- endfor %}
{%- endfor %}
},

@djmarcin
Copy link
Contributor Author

For this specific issue, it looks like there is a hacky workaround:

[package.metadata.raze.crates.tokio-compat-02.'*']
skipped_deps = [
  "tokio-0.3.3",
]
additional_deps = [
  "@raze__tokio__0_3_3//:tokio"
]

This results in deleting the tokio-0.3.3 dep which removes the alias, but then manually adds the dep back so that the build works. It would be nice to figure out why this erroneous alias was created in the first place though.

@UebelAndre
Copy link
Collaborator

At a quick glance. It seems like #282 might address this

@djmarcin
Copy link
Contributor Author

I also hit this issue with the oauth2 package just now, and the common thread seems to be that they use the package specifier inside the Cargo.toml dependency line to alias things. I see that sort of aliasing mentioned in that issue so 🤞 that it will solve it soon. For now, I can manually edit the generated files as a workaround (not all can be solved by simply removing/re-adding the dependency).

@GregBowyer
Copy link
Contributor

Almost certainly fixed by #282, is there a Cargo.toml I can test with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants