Skip to content

[9.0.0rc2] Confusing issue when load statement is missing for a provider #27684

@limdor

Description

@limdor

Description of the bug:

I'm not so sure how much this is a bug or a suboptimal user experience. The problem comes when trying to load https://github.com/limdor/bazel-examples/blob/9af2999e1331e85893dfecaa6bc7e9a4a05bc61c/linux_toolchain/toolchain/cc_toolchain_config.bzl in Bazel 9.0.0rc2

You get an error as follows:

ERROR: Traceback (most recent call last):
        File "/home/limdor/bazel-examples/linux_toolchain/toolchain/cc_toolchain_config.bzl", line 1682, column 27, in <toplevel>
                cc_toolchain_config = rule(
Error in rule: at index 0 of provides, got element of type NoneType, want Provider
ERROR: /home/limdor/bazel-examples/linux_toolchain/BUILD:4:11: While resolving toolchains for target //:buildifier (2396f3b): invalid registered toolchain '//toolchain:my_linux_toolchain': error loading package 'toolchain': initialization of module 'toolchain/cc_toolchain_config.bzl' failed

The problem is because in the following line https://github.com/limdor/bazel-examples/blob/9af2999e1331e85893dfecaa6bc7e9a4a05bc61c/linux_toolchain/toolchain/cc_toolchain_config.bzl#L1716 the provider CcToolchainConfigInfo is not known because the loading statement is missing.

The reason why I believe the error message is confusing is because usually when a load statement is missing you would expect something line:

name 'CcToolchainConfigInfo' is not defined

It looks like here Bazel is just ignoring CcToolchainConfigInfo and replacing it for a None type.
I put the category "C++ Rules" because I believe that this might be due to the special case of C++ providers were being before part of Bazel.

Which category does this issue belong to?

C++ Rules

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

In https://github.com/limdor/bazel-examples/tree/9af2999e1331e85893dfecaa6bc7e9a4a05bc61c/linux_toolchain with change the Bazel version to 9.0.0rc2 and build it with Ubuntu 24.04.

Which operating system are you running Bazel on?

Ubuntu 24.04

What is the output of bazel info release?

9.0.0rc2

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 response

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

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions