bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
648 stars 408 forks source link

no such target '@crate_index__jsonwebtoken-8.2.0//:jwt': target 'jwt' not declared in package #1809

Open QuentinPerez opened 1 year ago

QuentinPerez commented 1 year ago

:wave:

Just tried to add google-cloud-auth to my workspace and I faced this issue

no such target '@crate_index__jsonwebtoken-8.2.0//:jwt': target 'jwt' not declared in package '' 

is it a known one ?, otherwise I created a small repo to repro it https://github.com/QuentinPerez/rules_rust_jwt_tmp bazel run //:bin should be good enough.

hobofan commented 1 year ago

That looks like for some reason the aliasing they did in google-cloud-auth from jwt -> jsonwebtoken isn't being picked up correctly. Considering that the aliasing of json -> serde_json in the same crate is being picked up, that seems quite strange.

It looks like there is a bench target under the name jwt defined in the jsonwebtoken crate (though no Bazel target is generated for that). Maybe this throws off the normal alias mechanism?


If you need to work around this short-term you should be able to patch the google-cloud-auth dependency via a crate annotation so that these parts change from:

    deps = [
       ...
       "@crate_index__jsonwebtoken-8.2.0//:jwt",
       ...
    ]
    aliases = {
        "@crate_index__serde_json-1.0.91//:serde_json": "json",
    },

to this:

    deps = [
       ...
       "@crate_index__jsonwebtoken-8.2.0//:jsonwebtoken",
       ...
    ]
    aliases = {
        "@crate_index__serde_json-1.0.91//:serde_json": "json",
        "@crate_index__jsonwebtoken-8.2.0//:jsonwebtoken": "jwt",
    },