bazelbuild/bazel

Vendoring incorrectly evaluates what to vendor when `test --build_tests_only` is set

Open

#26,107 建立於 2025年5月20日

在 GitHub 查看
 (10 留言) (0 反應) (1 負責人)Java (4,465 fork)batch import
P3help wantedteam-ExternalDepstype: bug

倉庫指標

Star
 (25,384 star)
PR 合併指標
 (平均合併 22天 20小時) (30 天內合併 77 個 PR)

描述

Description of the bug:

Trying to vendor dependencies for a specific target in our bazel project, I noticed a certain repository was not vendored. It turns out disabling the following setting in our .bazelrc fixed it: test --build_tests_only

Which category does this issue belong to?

External Dependency

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

#MODULE.bazel 
module(
    name = "vendoring",
)

http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

http_file(
    name = "bazel.MODULE",
    downloaded_file_path = "bazel.MODULE",
    urls = [
        "https://raw.githubusercontent.com/bazelbuild/bazel/refs/heads/master/MODULE.bazel",
    ],
)

#BUILD.bazel
genrule(
    name = "fake_target",
    srcs = [
        "@bazel.MODULE//file:bazel.MODULE",
    ],
    outs = [
        "out.txt",
    ],
    cmd = "cat $(location @bazel.MODULE//file:bazel.MODULE) > $@",
)


#.bazelrc
test --build_tests_only

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 8.2.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

Discussed on bazel slack: https://bazelbuild.slack.com/archives/C014RARENH0/p1747728318774869

Any other information, logs, or outputs that you want to share?

No response

貢獻者指南