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

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

Closed
sgowroji opened this issue Apr 3, 2024 · 25 comments
Assignees
Labels
breakage P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@sgowroji
Copy link
Member

sgowroji commented Apr 3, 2024

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

Platform: Ubuntu, MacOs, Windows

Logs:

ERROR: �[0merror 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: 74c8ca4

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
@sgowroji sgowroji added type: bug breakage team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged labels Apr 3, 2024
@brentleyjones
Copy link
Contributor

They need to depend on the newer @platforms. We fixed this in apple_support here: bazelbuild/apple_support@a1c4ec2.

@Wyverald
Copy link
Member

Wyverald commented Apr 3, 2024

This is an unfortunate issue only with WORKSPACE -- Bazel itself already ships with the latest @platforms bundled, but there's no way to "force" that to be the version to be used. With Bzlmod, bazel_tools depends on the latest platforms, so there's no issue.

@Wyverald
Copy link
Member

Wyverald commented Apr 3, 2024

This also means that 74c8ca4 is not cherry-pickable back to 7.2.0. Hmm... I might need to come up with some halfway solution here.

@fmeum
Copy link
Collaborator

fmeum commented Apr 4, 2024

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.

@Wyverald
Copy link
Member

Wyverald commented Apr 4, 2024

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.

Wyverald added a commit that referenced this issue Apr 4, 2024
… platform repo rule

#21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.

To solve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.

Work towards #18285.

Fixes #21877.
fweikert pushed a commit to fweikert/bazel that referenced this issue Apr 8, 2024
… platform repo rule

bazelbuild#21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.

To resolve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.

This only affects WORKSPACE users; if `--enable_bzlmod` is set, the `@host_platform` seen by `@bazel_tools` will come from the module extension instead.

Work towards bazelbuild#18285.

Fixes bazelbuild#21877.

Closes bazelbuild#21902.

PiperOrigin-RevId: 622238362
Change-Id: I6335ab1bc26ba9ef54473d8a21fc5a8510a3ace5
@meteorcloudy meteorcloudy reopened this Apr 10, 2024
@meteorcloudy
Copy link
Member

Downstream projects are still failing: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/3783

@fmeum
Copy link
Collaborator

fmeum commented Apr 10, 2024

The problem is that @local_config_platform//:constraints.bzl reexports the constraints that now live in @platforms, which fails if the platforms repo isn't version 0.0.9 or higher.

We could reexport the constraints from the fake platforms repo instead when using WORKSPACE only. Maybe we also need to do this for the host alias?

Wyverald added a commit that referenced this issue Apr 16, 2024
Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.

Fixes #21877.
Wyverald added a commit that referenced this issue Apr 16, 2024
Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.

Fixes #21877.
@meteorcloudy meteorcloudy added P1 I'll work on this now. (Assignee required) and removed untriaged labels Apr 16, 2024
@meteorcloudy
Copy link
Member

Looks like there are still platforms related failures in https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/3797

@meteorcloudy meteorcloudy reopened this Apr 17, 2024
@meteorcloudy
Copy link
Member

Oh, the fix was just submitted one hour ago, let's wait for another day.

@Wyverald
Copy link
Member

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.

@Wyverald
Copy link
Member

I've sent a change internally to fix the android_sdk_repository issue.

Regarding Stardoc, there honestly isn't a good fix... We can upgrade rules_dotnet to use a newer Stardoc (which properly uses starlark_doc_extract), but that requires setting up a bzl_library/filegroup target for the constraints.bzl file in local_config_platform, which is very hard to do in a backwards-compatible manner. Will need to think about it more.

@meteorcloudy
Copy link
Member

We need to move bzl_library into bazel_tools

bzl_library is currently in bazel_skylib, which is a dependency of everything. Can we do this in a backwards compatible way?

@Wyverald
Copy link
Member

We specifically didn't want to introduce a dependency on skylib from @platforms, which doesn't have any dependencies right now. It's not as easy as "just add skylib" because there's still WORKSPACE :)

@meteorcloudy
Copy link
Member

Oh, I meant making the change of moving bzl_library from bazel_skylib to bazel_tools itself to be backwards compatible. I guess we need to add some redirects to bazel_skylib to make sure everyone is using the same bzl_library?

@Wyverald
Copy link
Member

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

@Wyverald
Copy link
Member

See also bazelbuild/bazel-skylib#495 which would serve as a stop-gap in the meantime.

@meteorcloudy
Copy link
Member

Nice! /cc @comius

@fmeum
Copy link
Collaborator

fmeum commented Apr 24, 2024

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

Isn't that difficult to pull off since loads are entirely static? For bzl_library in bazel_skylib to be an alias of the one in bazel_tools, we would either need to add a minimum Bazel version requirement to that version of skylib or introduce repo rules with generated loads. The latter would probably break with WORKSPACE though since many skylib users don't call its dependency macro (which so far only registers a toolchain for unit tests).

@meteorcloudy
Copy link
Member

we would either need to add a minimum Bazel version requirement to that version of skylib or introduce repo rules with generated loads.

I think this is also the concern Ivo raised to me. I don't have great answers, maybe we can backport the bzl_library to bazel_tools change in older Bazel LTS releases to make it easier for users to adapt? So basically, users have to migrate to the latest minor Bazel releases to use the latest bazel_skylib, which should be easy theoretically.

Wyverald added a commit to bazelbuild/rules_dotnet that referenced this issue Apr 25, 2024
Wyverald added a commit to bazelbuild/stardoc that referenced this issue Apr 25, 2024
Wyverald added a commit to bazelbuild/stardoc that referenced this issue Apr 25, 2024
Wyverald added a commit to bazelbuild/rules_dotnet that referenced this issue Apr 25, 2024
Also updates to latest Stardoc version.

Addresses the rules_dotnet part of bazelbuild/bazel#21877.
tetromino pushed a commit to bazelbuild/stardoc that referenced this issue Apr 25, 2024
Wyverald added a commit that referenced this issue Apr 25, 2024
… platform repo rule

#21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.

To resolve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.

This only affects WORKSPACE users; if `--enable_bzlmod` is set, the `@host_platform` seen by `@bazel_tools` will come from the module extension instead.

Work towards #18285.

Fixes #21877.

Closes #21902.

PiperOrigin-RevId: 622238362
Change-Id: I6335ab1bc26ba9ef54473d8a21fc5a8510a3ace5
Wyverald added a commit that referenced this issue Apr 25, 2024
Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.

Fixes #21877.

Closes #22021.

PiperOrigin-RevId: 625613724
Change-Id: I17940e5d4fbd8a7690d9199f80b80ceb62b53d1a
Wyverald added a commit that referenced this issue Apr 25, 2024
The native repo rule `android_sdk_repository` used to load from `@local_config_platform//:constraints.bzl`; 74c8ca4 changed it to load from `@platforms//host:constraints.bzl`. This caused failures with WORKSPACE users, as `@platforms` might still refer to an old version of `platforms` which doesn't have the `host` package, even though `@local_config_platform` knows to redirect to the bundled, newer version of `platforms`.

This CL reverts that change, so `android_sdk_repository` now loads from `@local_config_platform` again. This is fine because both are native repo rules and will be deprecated at the same time.

Partially fixes #21877.

PiperOrigin-RevId: 627395814
Change-Id: I5761cde3c86190d6da3e3933aa1bef18e0dcca3e
purkhusid pushed a commit to bazelbuild/rules_dotnet that referenced this issue Apr 25, 2024
Also updates to latest Stardoc version.

Addresses the rules_dotnet part of bazelbuild/bazel#21877.
@Wyverald
Copy link
Member

All green now!

Wyverald added a commit that referenced this issue Apr 29, 2024
… platform repo rule

#21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.

To resolve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.

This only affects WORKSPACE users; if `--enable_bzlmod` is set, the `@host_platform` seen by `@bazel_tools` will come from the module extension instead.

Work towards #18285.

Fixes #21877.

Closes #21902.

PiperOrigin-RevId: 622238362
Change-Id: I6335ab1bc26ba9ef54473d8a21fc5a8510a3ace5
Wyverald added a commit that referenced this issue Apr 29, 2024
Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.

Fixes #21877.

Closes #22021.

PiperOrigin-RevId: 625613724
Change-Id: I17940e5d4fbd8a7690d9199f80b80ceb62b53d1a
Wyverald added a commit that referenced this issue Apr 29, 2024
The native repo rule `android_sdk_repository` used to load from `@local_config_platform//:constraints.bzl`; 74c8ca4 changed it to load from `@platforms//host:constraints.bzl`. This caused failures with WORKSPACE users, as `@platforms` might still refer to an old version of `platforms` which doesn't have the `host` package, even though `@local_config_platform` knows to redirect to the bundled, newer version of `platforms`.

This CL reverts that change, so `android_sdk_repository` now loads from `@local_config_platform` again. This is fine because both are native repo rules and will be deprecated at the same time.

Partially fixes #21877.

PiperOrigin-RevId: 627395814
Change-Id: I5761cde3c86190d6da3e3933aa1bef18e0dcca3e
Wyverald added a commit that referenced this issue Apr 30, 2024
… platform repo rule

#21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.

To resolve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.

This only affects WORKSPACE users; if `--enable_bzlmod` is set, the `@host_platform` seen by `@bazel_tools` will come from the module extension instead.

Work towards #18285.

Fixes #21877.

Closes #21902.

PiperOrigin-RevId: 622238362
Change-Id: I6335ab1bc26ba9ef54473d8a21fc5a8510a3ace5
Wyverald added a commit that referenced this issue Apr 30, 2024
Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.

Fixes #21877.

Closes #22021.

PiperOrigin-RevId: 625613724
Change-Id: I17940e5d4fbd8a7690d9199f80b80ceb62b53d1a
Wyverald added a commit that referenced this issue Apr 30, 2024
The native repo rule `android_sdk_repository` used to load from `@local_config_platform//:constraints.bzl`; 74c8ca4 changed it to load from `@platforms//host:constraints.bzl`. This caused failures with WORKSPACE users, as `@platforms` might still refer to an old version of `platforms` which doesn't have the `host` package, even though `@local_config_platform` knows to redirect to the bundled, newer version of `platforms`.

This CL reverts that change, so `android_sdk_repository` now loads from `@local_config_platform` again. This is fine because both are native repo rules and will be deprecated at the same time.

Partially fixes #21877.

PiperOrigin-RevId: 627395814
Change-Id: I5761cde3c86190d6da3e3933aa1bef18e0dcca3e
Kila2 pushed a commit to Kila2/bazel that referenced this issue May 13, 2024
… platform repo rule

bazelbuild#21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.

To resolve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.

This only affects WORKSPACE users; if `--enable_bzlmod` is set, the `@host_platform` seen by `@bazel_tools` will come from the module extension instead.

Work towards bazelbuild#18285.

Fixes bazelbuild#21877.

Closes bazelbuild#21902.

PiperOrigin-RevId: 622238362
Change-Id: I6335ab1bc26ba9ef54473d8a21fc5a8510a3ace5
Kila2 pushed a commit to Kila2/bazel that referenced this issue May 13, 2024
Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.

Fixes bazelbuild#21877.

Closes bazelbuild#22021.

PiperOrigin-RevId: 625613724
Change-Id: I17940e5d4fbd8a7690d9199f80b80ceb62b53d1a
Kila2 pushed a commit to Kila2/bazel that referenced this issue May 13, 2024
The native repo rule `android_sdk_repository` used to load from `@local_config_platform//:constraints.bzl`; bazelbuild@74c8ca4 changed it to load from `@platforms//host:constraints.bzl`. This caused failures with WORKSPACE users, as `@platforms` might still refer to an old version of `platforms` which doesn't have the `host` package, even though `@local_config_platform` knows to redirect to the bundled, newer version of `platforms`.

This CL reverts that change, so `android_sdk_repository` now loads from `@local_config_platform` again. This is fine because both are native repo rules and will be deprecated at the same time.

Partially fixes bazelbuild#21877.

PiperOrigin-RevId: 627395814
Change-Id: I5761cde3c86190d6da3e3933aa1bef18e0dcca3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakage P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
5 participants