Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bazel CI] Error While resolving toolchains for target //tests/base_rules/py_test. No matching toolchains found for types. #2850

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

Closed
sgowroji opened this issue May 2, 2025 · 7 comments · Fixed by #2861

Comments

@sgowroji
Copy link
Contributor

sgowroji commented May 2, 2025

CI: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/4641#01968ee3-034a-44a1-9599-541d19ea7f77

Platform: Ubuntu, MacOS, Debian

Logs:

ERROR: �[0m/var/lib/buildkite-agent/builds/bk-docker-vfmd/bazel-org-repo-root/rules_python/tests/base_rules/py_test/BUILD.bazel:18:19: While resolving toolchains for target //tests/base_rules/py_test:test_basic_windows_subject (b27383e): No matching toolchains found for types:
ERROR: �[0m/var/lib/buildkite-agent/builds/bk-docker-vfmd/bazel-org-repo-root/rules_python/tests/base_rules/py_test/BUILD.bazel:18:19: While resolving toolchains for target //tests/base_rules/py_test:test_mac_requires_darwin_for_execution_subject (8444979): No matching toolchains found for types:

Steps:

git clone https://github.com/bazelbuild/rules_python
git reset ea80366b29219d3dad8c90191c21b77a4525875a  --hard
export USE_BAZEL_VERSION=0b5216ffe029b5fb0d0090f15fc4781522aac6d3
bazel build  ... @rules_python//examples/wheel/... 

CC Greenteam @meteorcloudy

@rickeylev
Copy link
Collaborator

No matching toolchains found for types:
  @@bazel_tools//tools/test:default_test_toolchain_type: By default, tests are executed on the first execution platform that matches all constraints specified by the target platform. Either register the target platform (or a platform with at least the same constraints) as an execution platform, or override the default behavior by registering a custom toolchain for @bazel_tools//tools/test:default_test_toolchain_type.

We have some analysis tests that force the platform to windows/mac in order to test the windows code paths. Here's one of the failing ones mentioned in the error:

https://github.com/bazel-contrib/rules_python/blob/main/tests/base_rules/py_test/py_test_tests.bzl#L41

It sets config_settings:

 "//command_line_option:cpu": "darwin_x86_64",
 "//command_line_option:crosstool_top": CROSSTOOL_TOP,
 "//command_line_option:extra_toolchains": CC_TOOLCHAIN,
 "//command_line_option:platforms": [MAC_X86_64],

Where cc toolchain and crosstool are set to an no-op impl. Platforms is shown below.

I'm guessing either the "default_test_toolchain_type" Bazel sets up is misconfigured, the config state those tests enter isn't quite valid, or the custom platform definition used for the test isn't quite valid.

Here's the basic mac platform it uses: https://github.com/bazel-contrib/rules_python/blob/main/tests/support/BUILD.bazel#L27

platform(
    name = "mac",
    constraint_values = [
        "@platforms//os:macos",
    ],
)

@katre @gregestren -- Would one of you know about the "default test" toolchain type and/or if the config state/platform the test are switching to is correct?

@meteorcloudy
Copy link
Contributor

@fmeum
Copy link
Member

fmeum commented May 5, 2025

I will send a fix soon.

@fmeum
Copy link
Member

fmeum commented May 5, 2025

Sent #2861

github-merge-queue bot pushed a commit that referenced this issue May 5, 2025
…2861)

This is required as of
bazelbuild/bazel@2780393
as tests now require an execution platform that matches their target
constraints by default.

Fixes #2850
github-merge-queue bot pushed a commit that referenced this issue May 6, 2025
Fixes:
```
ERROR: /Users/fmeum/git/rules_python/tests/pypi/env_marker_setting/BUILD.bazel:3:30: Illegal ambiguous match on configurable attribute "platform_machine" in //tests/pypi/env_marker_setting:test_expr_python_full_version_lt_negative_subject:
@@platforms//cpu:aarch64
@@platforms//cpu:arm64
Multiple matches are not allowed unless one is unambiguously more specialized or they resolve to the same value. See https://bazel.build/reference/be/functions#select.
```

Work towards #2850.
Work towards #2826.
@sgowroji
Copy link
Contributor Author

sgowroji commented May 6, 2025

@fmeum
Copy link
Member

fmeum commented May 6, 2025

@sgowroji The downstream run you linked checked out rules_python at ea80366, which is from mid March.

Cc @meteorcloudy

@sgowroji
Copy link
Contributor Author

sgowroji commented May 6, 2025

@fmeum Sorry for the confusion. Thanks for pointing me about the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants