Skip to content

--inject_repository leads to rebuliding of external dependencies in Bazel 8 #27061

@neckbosov

Description

@neckbosov

Description of the bug:

I use rules_jvm_external to fetch Maven dependencies for my project. After migrating from Bazel 7 to Bazel 8, I noticed that external jars are constantly rebuilt after syncing the project in my IDE. Turns out that for some reason, the --inject_repository option leads to the re-creation of some jar manifests in rules_jvm_external. I'm reporting here because it seems to be a problem of Bazel itself, not the ruleset.

Which category does this issue belong to?

Java Rules

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

  1. Create the sample java project with Bazel, specify some maven dependencies, e.g.
    MODULE.bazel
module(
    name = "null",
    version = "0.1.0",
)

bazel_dep(name = "rules_java", version = "8.10.0")
bazel_dep(name = "rules_jvm_external", version = "6.7")

# Set up Maven repositories for dependencies
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
    name = "maven",
    artifacts = [
        "junit:junit:4.13.2",
    ],
    repositories = [
        "https://repo1.maven.org/maven2",
    ],
)
use_repo(maven, "maven")
  1. Build project with bazel build //...
  2. Create empty folder named repo in project directory
  3. Run bazel build --inject_repository=repo=./repo --execution_log_json_file=./sync-exec.json @maven//:junit_junit
  4. Run bazel build --execution_log_json_file=./sync-exec.json @maven//:junit_junit

Expected result: last two builds doesn't do anything, execution logs are empty

Actual result: some random jar manifests are rebuilt inside rules_jvm_external, logs are not empty.

Which operating system are you running Bazel on?

Fedora 42

What is the output of bazel info release?

release 8.1.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?

No, didn't find any issues related to --inject_repository

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

No response

Metadata

Metadata

Assignees

Labels

P1I'll work on this now. (Assignee required)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions