rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

@rules_python//python:repositories.bzl' does not contain symbol 'python_register_toolchains'

Open brettwooldridge opened this issue 3 years ago • 1 comments

🐞 bug report

Affected Rule

python_register_toolchains

Is this a regression?

no

Description

I have the following in my WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "a3a6e99f497be089f81ec082882e40246bfd435f52f4e82f37e89449b04573f6",
    strip_prefix = "rules_python-0.10.2",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.10.2.tar.gz",
)

load("@rules_python//python:repositories.bzl", "python_register_toolchains")
load("@rules_python//python:pip.bzl", "pip_install")

python_register_toolchains(
    name = "python3_9",
    python_version = "3.9",
)

load("@python3_9//:defs.bzl", "interpreter")

🔥 Exception or Error

When I run the build (of any target), I get the following error:

Starting local Bazel server and connecting to it...
ERROR: Traceback (most recent call last):
	File "/Users/brettw/Documents/dev/jnb-ping/WORKSPACE", line 99, column 49, in <toplevel>
		load("@rules_python//python:repositories.bzl", "python_register_toolchains")
Error: file '@rules_python//python:repositories.bzl' does not contain symbol 'python_register_toolchains'
ERROR: error loading package '': Encountered error while reading extension file 'defs.bzl': no such package '@python3_9//': error loading package 'external': Could not load //external package
INFO: Elapsed time: 10.370s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

🌍 Your Environment

MacOS 11.6.6 (Intel)

Output of bazel version:

Bazelisk version: development
Build label: 5.2.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 7 16:11:03 2022 (1654618263)
Build timestamp: 1654618263
Build timestamp as int: 1654618263

Rules_python version:

rules_python-0.10.2

brettwooldridge avatar Jul 26 '22 19:07 brettwooldridge

Do you have a minimal repro of the issue? My guess that something else in the WORKSAPCE file is pulling in an older version of rules_python that doesn't have that symbol.

mattem avatar Jul 26 '22 20:07 mattem

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

github-actions[bot] avatar Sep 09 '22 22:09 github-actions[bot]

+1 -- curious if folks have a workaround to ensure precedence or a simple technique with bazel query or something like that to find another rule that might be bringing rules_python in

aryeh-looker avatar Nov 23 '22 21:11 aryeh-looker

Found the culprit for my use-case, googleapis, which I bring into my workspace and uses an old version of rules python https://github.com/googleapis/googleapis/blob/master/WORKSPACE#L42

Appears that just setting up python rules before googleapis does the trick.

aryeh-looker avatar Nov 23 '22 21:11 aryeh-looker