Skip to content

0.71.0 regression in all_crate_deps from crates_vendor with mode=remote #4132

Description

@jwnimmer-tri

Description

When using crates_vendor with mode = "remote", the labels returned by all_crate_deps lost their repo name in rules_rust >= 0.71.0.

In 0.70.0 they look like Label("@crate//:tempfile-3.23.0"), while in 0.71.0 they look like Label("//tempfile-3.23.0"). Notice the lack of @crate in the label.

Reproduction steps

The following patch to rules_rust demonstrates the issue. When applied to 0.70.0, running bazel build //test/determinism:all will succeed. When applied to 0.71.0 or 0.71.3, it results in a Bazel error (ERROR: .../rules_rust/test/determinism/BUILD.bazel:4:12: no such package 'tempfile-3.23.0': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.).

--- test/determinism/BUILD.bazel
+++ test/determinism/BUILD.bazel
@@ -1,21 +1,11 @@
 load("//rust:defs.bzl", "rust_binary")
+load("//test/determinism/3rdparty/crates:defs.bzl", "all_crate_deps")
 
 rust_binary(
     name = "determinism_tester",
     srcs = ["determinism_tester.rs"],
     edition = "2021",
-    deps = [
-        "//test/determinism/3rdparty/crates:anyhow",
-        "//test/determinism/3rdparty/crates:blake3",
-        "//test/determinism/3rdparty/crates:clap",
-        "//test/determinism/3rdparty/crates:serde",
-        "//test/determinism/3rdparty/crates:serde_json",
-        "//test/determinism/3rdparty/crates:tempfile",
-        "//test/determinism/3rdparty/crates:tokio",
-        "//test/determinism/3rdparty/crates:tracing",
-        "//test/determinism/3rdparty/crates:tracing-subscriber",
-        "//test/determinism/3rdparty/crates:walkdir",
-    ],
+    deps = all_crate_deps(normal = True, package_name = ""),
 )
 
 alias(

Additional context

I believe the regression happened in #4093 or #4094 or thereabouts CC @UebelAndre.

Impact

I was able to work around the issue by running a perl pie over the generated crates.bzl to add back the labels.

Bazel and rules_rust version

Bazel 9.1.1 and rules_rust 0.71.0, 0.71.2, and 0.71.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThe ticket needs maintainer attention.

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions