bazel-contrib / bazel-contrib/rules_oci
Building oci_image on Windows (Git Bash) - Results in "No matching toolchains found for types @@aspect_bazel_lib~//lib:zstd_toolchain_type"
- Dominant language
- Starlark
- Stars
- 423
- Forks
- 213
- Avg merge
- 53m
- Merged PRs (30d)
- 1
Description
I'm working on migrating a bunch of disparate shell build scripts to Bazel.
The project consists of a set of grpc servers written in Go and exposed as their own binaries, each of which are subsequently built into `Containerfile` images running on top of `debian:bookworm-slim`, and spun up in a local Kubernetes cluster via Docker Desktop.
The problem I'm running into occurs when attempting to build the `oci_image` target for any of these grpc servers (with the recommended toolchain_resolution_debug flag enabled):
```
$ bazelisk build //src/services/identity/exec:image --toolchain_resolution_debug='@@aspect_bazel_lib~//lib:zstd_toolchain_type'
WARNING: Build option --toolchain_resolution_debug has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: ToolchainResolution: Performing resolution of @@aspect_bazel_lib~//lib:zstd_toolchain_type for target platform @@platforms//host:host
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_darwin_amd64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: osx
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_darwin_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: osx, aarch64
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_amd64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_arm64//:zstd_toolchain is compatible with target plaform, searching for execution p ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_darwin_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: osx, aarch64
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_amd64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_arm64//:zstd_toolchain is compatible with target plaform, searching for execution p ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: osx, aarch64
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_amd64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
latforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux, aarch64
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_darwin_amd64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: osx
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_darwin_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: osx, aarch64
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_amd64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux
ToolchainResolution: Toolchain @@aspect_bazel_lib~~toolchains~zstd_linux_arm64//:zstd_toolchain is compatible with target plaform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform @@platforms//host:host; mismatching values: linux, aarch64
ToolchainResolution: No @@aspect_bazel_lib~//lib:zstd_toolchain_type toolchain found for target platform @@platforms//host:host.
ERROR: C:/dev/go/curtain/src/services/identity/exec/BUILD:39:10: While resolving toolchains for target //src/services/identity/exec:image (b433496): No matching toolchains found for types @@aspect_bazel_lib~//lib:zstd_toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@@aspect_bazel_lib~//lib:zstd_toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
ERROR: Analysis of target '//src/services/identity/exec:image' failed; build aborted
INFO: Elapsed time: 1.956s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
```
IIUC, it looks like `aspect_bazel_lib` doesn't provide a toolchain for zstd that works on Windows?
Is this a legitimate support issue for Windows, or have I misconfigured something somewhere?
Are there any workarounds I can attempt to use?
Is there any additional information I can provide to narrow this down?
This may be at least partially related to https://github.com/bazel-contrib/rules_oci/issues/714, but I'm not totally sure.
Here's the relevant `BUILD` file for reference:
```
load("@rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
go_binary(
name = "main",
embed = [":exec_lib"],
visibility = ["//visibility:public"],
)
go_library(
name = "exec_lib",
srcs = ["main.go"],
importpath = "gitlab.com/jasonbdly/curtain/src/services/identity/exec",
visibility = ["//visibility:private"],
deps = [
"//src/core/cell",
"//src/core/service",
"//src/services/identity",
"//src/services/identity/models",
"@io_gorm_driver_mysql//:mysql",
"@io_gorm_gorm//:gorm",
],
)
pkg_tar(
name = "tar",
srcs = [":main"],
)
oci_image(
name = "image",
base = "@distroless_base",
entrypoint = ["/identity-service"],
tars = [":tar"],
)
# oci_push(
# name = "push",
# image = ":image",
# # remote_tags = [""],
# repository = "",
# )
```
And the `MODULE.bazel` file:
```
module(name = "curtain")
bazel_dep(name = "rules_go", version = "0.50.1")
bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "aspect_bazel_lib", version = "2.9.1")
bazel_dep(name = "gazelle", version = "0.39.1")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.4")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
# All *direct* Go dependencies of the module have to be listed explicitly.
use_repo(
go_deps,
"io_gorm_driver_mysql",
"io_gorm_gorm",
"org_golang_google_grpc",
"org_golang_google_protobuf",
"org_golang_x_crypto",
)
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "rules_oci", version = "2.0.0")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "distroless_base",
image = "gcr.io/distroless/base",
platforms = ["linux/amd64"],
# 'latest' is not reproducible, but it's convenient.
# During the build we print a WARNING message that includes recommended 'digest' and 'platforms'
# values which you can use here in place of 'tag' to pin for reproducibility.
tag = "latest",
)
use_repo(oci, "distroless_base", "distroless_base_linux_amd64")
```
The output from `bazelisk version`:
```
$ bazelisk version
Bazelisk version: v1.22.0
Build label: 7.3.2
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Tue Oct 1 17:49:08 2024 (1727804948)
Build timestamp: 1727804948
Build timestamp as int: 1727804948
```
Contributor guide
Research direction
Reproduce the failure from src/services/identity/exec/BUILD and MODULE.bazel with the shown Bazelisk command and zstd toolchain debug flag. Inspect the rules_oci and aspect_bazel_lib zstd toolchain declarations for Windows compatibility and compare them with the reported host-platform resolution. Done means establishing whether Windows is supported and documenting or validating a working configuration or workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go, kubernetes
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100