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

SurrealDB dependency triggers no such target //:executor' ... error. Possible bug? #2571

Open
marvin-hansen opened this issue Mar 24, 2024 · 0 comments

Comments

@marvin-hansen
Copy link

marvin-hansen commented Mar 24, 2024

  • BAZEL_VERSION=7.1.1
  • RUST_VERSION = "1.76.0"
  • OS: MacOS Sonoma 14.4
  • Apple M3 Max (ARM64)

Repo to reproduce: bazel_rust

Hi, I'm setting up a Rust mono repo with > 35 crates. I am generating all dependencies with crate_universe, exactly as described in the documentation. While configuring Bazel for the first crate, I stumbled across the following error when running bazel build

defined by /private/var/tmp/_bazel_marvin/9cf0c27c2f651654c121c526ef57328f/external/crate_index__async-executor-1.8.0/BUILD.bazel

ERROR: /private/var/tmp/_bazel_marvin/9cf0c27c2f651654c121c526ef57328f/external/crate_index__surrealdb-core-1.3.1/BUILD.bazel:16:13: 
no such target '@@crate_index__async-executor-1.8.0//:executor': target 'executor' not declared in package '' 
defined by /private/var/tmp/_bazel_marvin/9cf0c27c2f651654c121c526ef57328f/external/
crate_index__async-executor-1.8.0/BUILD.bazel 
and referenced by '@@crate_index__surrealdb-core-1.3.1//:surrealdb_core'

When I query the dependency in question:

 bazel query "@crate_index__async-executor-1.8.0//:*"

It is indeed true that there is no target executor, only an async_executor.
However, there is an executor target in the benches and I wonder if the generated specs somehow mixed these up?

Output:

@crate_index__async-executor-1.8.0//:LICENSE-APACHE
@crate_index__async-executor-1.8.0//:LICENSE-MIT
@crate_index__async-executor-1.8.0//:README.md
@crate_index__async-executor-1.8.0//:async_executor
@crate_index__async-executor-1.8.0//:benches/executor.rs....

The SurrealDB/Core crate seems to trigger the issue. AFAIK, SurrealDB adds some 150 dependencies, and, among others, the async-executor that throws the error.

Is this a bug in the rules, or did I misconfigured something?

Is there any known workaround for this kind of undeclared error from a generated dependency?

Any help would be appriciated.

Thank you,
Marvin

I created a self-contained example to reproduce the issue:

https://github.com/marvin-hansen/bazel_rust

Here is the Build file:

load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_library")

rust_library(
    name = "common",
    srcs = glob([
        "src/types/**/*.rs",
        "src/utils/**/*.rs",
    ]),
    aliases = aliases(),
    proc_macro_deps = all_crate_deps(proc_macro = True),
    deps = all_crate_deps(normal = True),
    visibility = ["//visibility:public"],
)

And the WORKSPACE file:

workspace(name = "queng")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "bazel_skylib",
    sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
    ],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

# To find additional information on this release or newer ones visit:
# https://github.com/bazelbuild/rules_rust/releases
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_rust",
    integrity = "sha256-ww398ehv1QZQp26mRbOkXy8AZnsGGHpoXpVU4WfKl+4=",
    urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.40.0/rules_rust-v0.40.0.tar.gz"],
)

RUST_VERSION = "1.76.0"

# Configure Rust Toolchain to use.
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
rules_rust_dependencies()
rust_register_toolchains(
    edition = "2021",
    versions = [
        RUST_VERSION,
    ],
)

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies()

# Track dependencies of all crates.
# When you add a new crate, re-run:
# CARGO_BAZEL_REPIN=true bazel sync --only=crate_index
load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
crates_repository(
    name = "crate_index",
    cargo_lockfile = "//:Cargo.lock",
    lockfile = "//:cargo-bazel-lock.json",
    manifests = [
        "//:Cargo.toml",
        "//:queng_common/Cargo.toml",
    ],
)

load("@crate_index//:defs.bzl", "crate_repositories")
crate_repositories()
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

1 participant