Skip to content
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

pip_repository.bzl: name 'json' is not defined #978

Closed
yin opened this issue Jan 10, 2023 · 2 comments
Closed

pip_repository.bzl: name 'json' is not defined #978

yin opened this issue Jan 10, 2023 · 2 comments

Comments

@yin
Copy link

yin commented Jan 10, 2023

Affected Rule

None, build fails in docker image.

Is this a regression?

N/A - Greenfield project, first time using Bazel.

Description

The problem occurs only when running Bazel in the docker image l.gcr.io/google/bazel. I am trying to set up CI to test, build and run coverage on GitLab CI. I added Python 3.10 toolchain and had to workaround #932

The rule causes the issue:
When the build is run in the docker image, I get an error about a builtin json module: pip_repository.bzl:175:13: name 'json' is not defined

See https://gitlab.com/yin2/language/-/jobs/3583021972

There's the full error output. json() should be a built-in function.

🔬 Minimal Reproduction

Try cloning https://gitlab.com/yin2/language and upload it to your GitLab account. Alternatively, run docker image l.gcr.io/google/bazel:latest with the cloned sources mounted and run bazel build.

🔥 Exception or Error


$ bazel build //...
INFO: Invocation ID: b44126dd-d90f-4cf9-b41a-895b26a590cd
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
ERROR: /root/.cache/bazel/_bazel_root/4755c6ea53a31c010470a9916f8665[40](https://gitlab.com/yin2/language/-/jobs/3583021972#L40)/external/rules_python/python/pip_install/pip_repository.bzl:175:13: name 'json' is not defined
ERROR: /root/.cache/bazel/_bazel_root/4755c6ea53a31c010470a9916f866540/external/rules_python/python/pip_install/pip_repository.bzl:184:13: name 'json' is not defined
ERROR: /root/.cache/bazel/_bazel_root/4755c6ea53a31c010470a9916f866540/external/rules_python/python/pip_install/pip_repository.bzl:193:13: name 'json' is not defined
ERROR: /root/.cache/bazel/_bazel_root/4755c6ea53a31c010470a9916f866540/external/rules_python/python/pip_install/pip_repository.bzl:298:29: name 'json' is not defined
ERROR: /root/.cache/bazel/_bazel_root/[47](https://gitlab.com/yin2/language/-/jobs/3583021972#L47)55c6ea53a31c010470a9916f866540/external/rules_python/python/pip_install/pip_repository.bzl:300:33: name 'json' is not defined
ERROR: /root/.cache/bazel/_bazel_root/4755c6ea53a31c010470a9916f866540/external/rules_python/python/pip_install/pip_repository.bzl:608:12: name 'json' is not defined
ERROR: error loading package '': in /root/.cache/bazel/_bazel_root/4755c6ea53a31c010470a9916f866540/external/rules_python/python/pip.bzl: Extension 'python/pip_install/pip_repository.bzl' has errors
INFO: Elapsed time: 3.259s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

🌍 Your Environment

Output of bazel version:

See https://gitlab.com/yin2/language/-/jobs/3583021972

Rules_python version:

See https://gitlab.com/yin2/language/-/jobs/3583021972

@groodt
Copy link
Collaborator

groodt commented Jan 11, 2023

It looks like you are using the following versions:
Python 2.7.12
Bazel 3.5.0
rules_python_version "9bf7c49ea1920e497f857ccc1e9c2d1189c8a1c9" # Latest @ 2021-06-23

All of these are very old versions. Both those python versions and bazel versions have fallen out of LTS support. Regrettably, the maintainers are unlikely to be able to invest time investigating or fixing this issue. I suggest upgrading to supported versions of these tools.

@groodt groodt closed this as completed Jan 11, 2023
@yin
Copy link
Author

yin commented Jan 26, 2023

FYI... I was using an old un-updated docker image. The correct image to use is: gcr.io/bazel-public/bazel:6.0.0

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

No branches or pull requests

2 participants