bazel: [Bazel CI] Error with Label '@@platforms//host:extension.bzl' is invalid because 'host' is not a package

CI: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/3769

Platform: Ubuntu, MacOs, Windows

Logs:

ERROR: error loading package '': Label '@@platforms//host:extension.bzl' is invalid because 'host' is not a package; perhaps you meant to put the colon here: '@@platforms//:host/extension.bzl'?

Culprit: https://github.com/bazelbuild/bazel/commit/74c8ca4886cfc188d60a18e796743e842f675842

CC Greenteam @fweikert @meteorcloudy @Wyverald

Few downstream projects are failing with below error

  1. Gerrit
  2. Kythe
  3. Stardoc
  4. Protobuf
  5. rules_dotnet
  6. rules_foreign_cc
  7. rules_go
  8. rules_haskell

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Not really – Stardoc dropping WORKSPACE support doesn’t help with this specific issue. Projects using old Stardoc (pre-starlark_doc_extract) will fail anyway with Bzlmod; projects using newer Stardoc will be broken because they need to update their bzl_library deps. This is very unsatisfactory but is an unfortunately consequence of bzl_library being in bazel_skylib. We need to move bzl_library into bazel_tools and then we could properly set up bzl_library targets for .bzl files in @bazel_tools, @platforms, etc.

Changing the flag default based on another flag sounds pretty error-prone. But I think I can safely change what @bazel_tools//tools:host_platform aliases to based on the value of --enable_bzlmod.

also add the separate setup step for the generated repo.

This part is unnecessary; it’s done in the WORKSPACE suffix. In fact it’s what’s causing the current breakage…

Since WORKSPACE users won’t benefit from the future improvements to constraint registration, that pain won’t pay off for them anyway.

I mostly wanted to deprecate the native repo rule. I guess that’s still doable, we just need to ship a copy of @@platforms//host:extension.bzl in Bazel 7.x. Which isn’t the end of the world, but the setup is getting quite convoluted.

All green now!

ah, I see – yes, that’s the plan. bzl_library in bazel_skylib would just be an alias for its counterpart in bazel_tools.

Still not fixed… https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/3801#018ef488-87d2-4d8d-ac56-65762421b4a0

Looks like this still fails when Stardoc and/or android_sdk_repository are involved. Will take a look.

Could we just keep the default value of --host_platform as is for WORKSPACE (i.e., depending on the --enable_bzlmod flag)? Realistically speaking all WORKSPACE projects would otherwise have to manually bump platforms and also add the separate setup step for the generated repo. Since WORKSPACE users won’t benefit from the future improvements to constraint registration, that pain won’t pay off for them anyway.