Loading rules_python should not depend on known python versions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- build-system
Hướng nghiên cứu
Tái hiện lỗi bằng bazel run @rules_python//python/bin:repl với cấu hình MODULE.bazel được cung cấp. Bắt đầu với python/extensions:python.bzl và python/private/python_register_toolchains.bzl, đặc biệt là dòng 106 được báo cáo, để theo dõi lý do phiên bản hệ thống được kiểm tra trước phiên bản đã cấu hình. Hoàn tất khi có thể cấu hình một phiên bản python.toolchain hợp lệ mà không xảy ra lỗi do phiên bản Python hệ thống không xác định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🐞 bug report
Affected Rule
The issue is caused by the rule:python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Loading python seems to check the system python version. This makes it impossible to use rules_python if the version is not in its version dict:
File "$BUILD/external/rules_python+/python/private/python_register_toolchains.bzl", line 106, column 31, in python_register_toolchains
sha256 = tool_versions[python_version]["sha256"].get(platform, None)
Error: key "3.14.0b2" not found in dictionary
ERROR: Analysis of target '@@rules_python+//python/bin:repl' failed; build aborted:
error evaluating module extension @@rules_python+//python/extensions:python.bzl%python
Note that this happens when loading the python extension, which is required to configure the python version, creating a catch 22.
Is this a regression?
I have found other occurrences (1,2) of the error message (as below) but I don't think it was traced to this before. It it likely a regression that happens every now and then when some python version gets a weird id and due to the hard coded map of versions in rules_python.
Description
Nothing that depends on rules_python builds. Simplest example
bazel run @rules_python//python/bin:repl
🔬 Minimal Reproduction
This depends on your system python, so it may be best to reproduce in a container. I am running Manjaro with python up to date. The exact python version is 3.14.2 (main, Jan 2 2026, 14:27:39) [GCC 15.2.1 20251112].
Relevant package information (from pacman -Qi python):
Name : python
Version : 3.14.2-2
Architecture : x86_64
Build Date : Fri 02 Jan 2026 03:27:39 PM CET
Install Date : Wed 11 Feb 2026 10:13:47 PM CET
Here's my entire python MODULE.bazel setup section (tried older versions of rules_python as well):
bazel_dep(name = "rules_python", version = "1.9.0-rc0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.13",
)
use_repo(python, "python_toolchains")
register_toolchains("@python_toolchains//:all")
🔥 Exception or Error
$ bazel run @rules_python//python/bin:repl
Starting local Bazel server (8.5.1) and connecting to it...
ERROR: $BUILD/external/rules_python+/python/private/python_register_toolchains.bzl:106:31: Traceback (most recent call last):
File "$BUILD/external/rules_python+/python/private/python.bzl", line 273, column 53, in _python_impl
register_result = python_register_toolchains(
File "$BUILD/external/rules_python+/python/private/python_register_toolchains.bzl", line 106, column 31, in python_register_toolchains
sha256 = tool_versions[python_version]["sha256"].get(platform, None)
Error: key "3.14.0b2" not found in dictionary
ERROR: Analysis of target '@@rules_python+//python/bin:repl' failed; build aborted: error evaluating module extension @@rules_python+//python/extensions:python.bzl%python
The expectation would be that the unknown python version is ignored as long as a valid python version is configured via python.toolchain(version=$KNOWN_VERSION}). Whatever else depends on the system python version before is quite likely an isolation failure wrt. reproducibility.
🌍 Your Environment
Operating System:
Linux $HOSTNAME 6.18.8-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri, 30 Jan 2026 23:06:21 +0000 x86_64 GNU/Linux
Output of bazel version:
bazel 8.5.1
Confirmed on 9.0.0 as well
Rules_python version:
1.9.0-rc0, 1.84.0
Anything else relevant?
- Ngôn ngữ chính
- Starlark
- Star
- 690
- Fork
- 722
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 50
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bazel-contrib/rules_python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bazel-contrib/rules_python#4164 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bazel-contrib/rules_python#3821 ·
-
Release 2.4.0 Đang mởtype: release
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
bazel-contrib/rules_python#4175 · 3 bình luận ·
-
Release 2.3.4 Đang mởtype: release
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
bazel-contrib/rules_python#4173 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
bazel-contrib/rules_python#4171 ·
Tất cả issue của bazel-contrib/rules_python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
CS0162 "Unreachable code detected" warning from a MSBuildTemp .tmp file in every game project Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
area:engineering priority:p2 type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
jejjohnson/pyrox#234 ·
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
ros2/ros2_tracing#266 · 1 bình luận ·