admin管理员组

文章数量:1318563

I had to roll back a bazel upgrade from 8.x back to 7.x because of the following error occuring in my builds.

no such package '@@[unknown repo 'platforms' requested from @@]//os': The repository '@@[unknown repo 'platforms' requested from @@]' could not be resolved: No repository visible as '@platforms' from main repository

What do I need to change to fix it ? I'm still a bit of a bazel noob.

My module.bazel:

module(
    name = "REDACTED",
    version = "0.1.0",
)

bazel_dep(name = "rules_go", version = "0.52.0")
bazel_dep(name = "gazelle", version = "0.41.0")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.nogo(nogo = "//:my_nogo")
go_sdk.download(version = "1.23.4")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_github_aws_aws_sdk_go_v2", "com_github_aws_aws_sdk_go_v2_config", "com_github_aws_aws_sdk_go_v2_service_sesv2", "com_github_go_acme_lego_v4", "com_github_jackc_pgx_v5", "com_github_jub0bs_cors", "com_github_prometheus_client_golang", "com_github_prometheus_client_model", "com_github_prometheus_common", "io_opentelemetry_go_otel", "_golang_google_protobuf", "_golang_x_crypto", "_golang_x_net")

My build.bazel:

load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "nogo")

#gazelle:map_kind go_binary go_binary //rules/go:rules_go.bzl

gazelle(name = "gazelle")

gazelle(
    name = "gazelle-update-repos",
    args = [
        "-from_file=go.mod",
        "-prune",
    ],
    command = "update-repos",
)

gazelle(
    name = "gazelle-fix",
    command = "fix",
)

nogo(
    name = "my_nogo",
    vet = True,
    visibility = ["//visibility:public"],
)

My .bazelrc:

build:mac_arm64 --platforms=@rules_go//go/toolchain:darwin_arm64 --stamp --workspace_status_command="$(pwd)/version.sh"
build:linux_amd64 --platforms=@rules_go//go/toolchain:linux_amd64 --stamp --workspace_status_command="$(pwd)/version.sh"
build:bsd_amd64 --platforms=@rules_go//go/toolchain:openbsd_amd64 --stamp --workspace_status_command="$(pwd)/version.sh"

I had to roll back a bazel upgrade from 8.x back to 7.x because of the following error occuring in my builds.

no such package '@@[unknown repo 'platforms' requested from @@]//os': The repository '@@[unknown repo 'platforms' requested from @@]' could not be resolved: No repository visible as '@platforms' from main repository

What do I need to change to fix it ? I'm still a bit of a bazel noob.

My module.bazel:

module(
    name = "REDACTED",
    version = "0.1.0",
)

bazel_dep(name = "rules_go", version = "0.52.0")
bazel_dep(name = "gazelle", version = "0.41.0")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.nogo(nogo = "//:my_nogo")
go_sdk.download(version = "1.23.4")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_github_aws_aws_sdk_go_v2", "com_github_aws_aws_sdk_go_v2_config", "com_github_aws_aws_sdk_go_v2_service_sesv2", "com_github_go_acme_lego_v4", "com_github_jackc_pgx_v5", "com_github_jub0bs_cors", "com_github_prometheus_client_golang", "com_github_prometheus_client_model", "com_github_prometheus_common", "io_opentelemetry_go_otel", "_golang_google_protobuf", "_golang_x_crypto", "_golang_x_net")

My build.bazel:

load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "nogo")

#gazelle:map_kind go_binary go_binary //rules/go:rules_go.bzl

gazelle(name = "gazelle")

gazelle(
    name = "gazelle-update-repos",
    args = [
        "-from_file=go.mod",
        "-prune",
    ],
    command = "update-repos",
)

gazelle(
    name = "gazelle-fix",
    command = "fix",
)

nogo(
    name = "my_nogo",
    vet = True,
    visibility = ["//visibility:public"],
)

My .bazelrc:

build:mac_arm64 --platforms=@rules_go//go/toolchain:darwin_arm64 --stamp --workspace_status_command="$(pwd)/version.sh"
build:linux_amd64 --platforms=@rules_go//go/toolchain:linux_amd64 --stamp --workspace_status_command="$(pwd)/version.sh"
build:bsd_amd64 --platforms=@rules_go//go/toolchain:openbsd_amd64 --stamp --workspace_status_command="$(pwd)/version.sh"
Share Improve this question asked Jan 21 at 10:50 Little CodeLittle Code 1,5454 gold badges20 silver badges45 bronze badges 3
  • 1 IIRC I've seen something like that when I've tried to reference a module I did not (explicitly) declare as deps (that previously could be implied in older versions)... in my case @rules_cc. Adding @platforms to you project's MODULE.bazel may be it, but call it just a hunch -> I'll only drop it as comment. – Ondrej K. Commented Jan 22 at 10:59
  • Thanks for the idea to try @OndrejK. I will try that when I get a chance later this week. – Little Code Commented Jan 22 at 12:18
  • 1 You are right @OndrejK. Underlying reason is Bazel 8 no longer accepts indirect dependencies (in my case, platforms via rules_go). You now have to declare explicitly: github/bazel-contrib/rules_go/issues/… – Little Code Commented Jan 22 at 18:57
Add a comment  | 

1 Answer 1

Reset to default 0

Bazel 8 no longer accepts indirect dependencies (in my case, platforms via rules_go). You now have to declare explicitly:

https://github/bazel-contrib/rules_go/issues/4192#issuecomment-2532276415

本文标签: bazel 8no such package 39unknown repo 39platforms39 requested from os39Stack Overflow