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

--incompatible_disable_native_repo_rules is incompatible with --noenable_bzlmod #23206

Open
dgp1130 opened this issue Aug 5, 2024 · 1 comment
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@dgp1130
Copy link
Contributor

dgp1130 commented Aug 5, 2024

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

@github-actions github-actions bot added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Aug 5, 2024
dgp1130 added a commit to dgp1130/rules_prerender that referenced this issue Aug 5, 2024
Tried to enable this and found one missing `load` statement in the external example. However this option appears to just be broken with `--enable_bzlmod` as it triggers an error in a non-existant `WORKSPACE` file, even if the actual `WORKSPACE` file is empty. I filed bazelbuild/bazel#23206, as it appears to be a core Bazel bug. `--enable_bzlmod` breaks a bunch of things here and I haven't had time to properly look into it, so I think it's best to just leave `--incompatible_disable_native_repo_rules` off for now.
@fmeum fmeum added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. and removed team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Aug 5, 2024
@meteorcloudy
Copy link
Member

This comes from the default WORKSPACE prefix that introduces bazel_tools as a local_repository:

local_repository(
name = "bazel_tools",
path = __embedded_dir__ + "/embedded_tools",
repo_mapping = {"@rules_java" : "@rules_java_builtin"}
)

/cc @Wyverald

@meteorcloudy meteorcloudy added P1 I'll work on this now. (Assignee required) and removed untriaged labels Aug 13, 2024
@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) and removed P1 I'll work on this now. (Assignee required) labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

7 participants