Skip to content

cc_shared_library doesn't work with Bzlmod enabled #19822

@meteorcloudy

Description

@meteorcloudy

Description of the bug:

When Bzlmod is enabled, //src/main/starlark/tests/builtins_bzl:cc_builtin_tests fails with

ERROR: /usr/local/google/home/pcloudy/.cache/bazel/_bazel_pcloudy/4c5ccabacef1ddac6600d71a1b8bfa58/sandbox/linux-sandbox/3278/execroot/_main/_tmp/53b71ca53f550b44b438a63fa52d0916/workspace/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD:372:11: in path_matching_test_test rule //src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:path_matching_test:
Traceback (most recent call last):
	File "/usr/local/google/home/pcloudy/.cache/bazel/_bazel_pcloudy/4c5ccabacef1ddac6600d71a1b8bfa58/sandbox/linux-sandbox/3278/execroot/_main/_tmp/53b71ca53f550b44b438a63fa52d0916/root/6b43bf36e07619ef843bbf3707ed48d2/external/rules_testing/lib/analysis_test.bzl", line 196, column 13, in wrapped_impl
		impl(env, target)
	File "/usr/local/google/home/pcloudy/.cache/bazel/_bazel_pcloudy/4c5ccabacef1ddac6600d71a1b8bfa58/sandbox/linux-sandbox/3278/execroot/_main/_tmp/53b71ca53f550b44b438a63fa52d0916/workspace/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl", line 153, column 53, in _paths_test_impl
		env.expect.that_bool(_check_if_target_under_path(Label("@foo//foo"), Label("@bar//bar"))).equals(False)
	File "/usr/local/google/home/pcloudy/.cache/bazel/_bazel_pcloudy/4c5ccabacef1ddac6600d71a1b8bfa58/sandbox/linux-sandbox/3278/execroot/_main/_tmp/53b71ca53f550b44b438a63fa52d0916/workspace/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl", line 37, column 15, in _check_if_target_under_path
		if pattern.workspace_name != value.workspace_name:
Error: 'workspace_name' is not allowed on invalid Label @[unknown repo 'bar' requested from @]//bar:bar

Which category does this issue belong to?

C++/Objective-C Rules

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

To reproduce:

  • Remove disable_bzlmod from src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh
  • bazel test //src/main/starlark/tests/builtins_bzl:cc_builtin_tests

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

No response

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 master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

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

Discovered while turning on Bzlmod in shell tests: #19785

Metadata

Metadata

Labels

P2We'll consider working on this in future. (Assignee optional)team-Rules-CPPIssues for C++ rulestype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions