bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.2k stars 4.06k forks source link

`--incompatible_disable_native_repo_rules` is incompatible with `--noenable_bzlmod` #23206

Open dgp1130 opened 3 months ago

dgp1130 commented 3 months ago

Description of the bug:

If you set both --incompatible_disable_native_repo_rules and --noenable_bzlmod, any bazel build fails with the following error (even if you have an empty WORKSPACE.bazel file).

ERROR: /DEFAULT.WORKSPACE:1:17: fetching local_repository rule //external:bazel_tools: Native repo rule local_repository is disabled since the flag --incompatible_disable_native_repo_rules is set. Native repo rules are deprecated; please migrate to their Starlark counterparts. For local_repository, please use load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository"). ERROR: Error computing the main repository mapping: no such package '@@bazel_tools//tools/build_defs/repo': Native repo rule local_repository is disabled since the flag --incompatible_disable_native_repo_rules is set. Native repo rules are deprecated; please migrate to their Starlark counterparts. For local_repository, please use load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository").__

Which category does this issue belong to?

Core

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

Enabling both flags seems to be enough to trigger the bug in any workspace.

bazel build //some:target --incompatible_disable_native_repo_rules --noenable_bzlmod

But I created a minimal repro (literally an empty workspace) just to demonstrate that there's no local configuration issue related here: https://github.com/dgp1130/bazel-native-rules-bzlmod

Which operating system are you running Bazel on?

Linux via WSL

What is the output of bazel info release?

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

git@github.com:dgp1130/bazel-native-rules-bzlmod
19acb3fda0ca7361fe82342224550f91ee6b0959

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 response

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

No response

meteorcloudy commented 2 months ago

This comes from the default WORKSPACE prefix that introduces bazel_tools as a local_repository: https://github.com/bazelbuild/bazel/blob/5156558beb0ab639f9bfd17856b42d6ef32d5017/src/main/java/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE#L1-L5

/cc @Wyverald