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

gazelle: ERROR: failed to parse: read |0: file already closed #1315

Closed
siennathesane opened this issue Jul 14, 2023 · 2 comments
Closed

gazelle: ERROR: failed to parse: read |0: file already closed #1315

siennathesane opened this issue Jul 14, 2023 · 2 comments
Labels
gazelle Gazelle plugin related issues

Comments

@siennathesane
Copy link

🐞 bug report

Affected Rule

I believe it is this one:

load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
gazelle(
    name = "gazelle",
    data = GAZELLE_PYTHON_RUNTIME_DEPS,
    gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)

Is this a regression?

I don't know, I'm a new user

Description

Gazelle fails to generate build configurations

🔬 Minimal Reproduction

I don't know how to reproduce this, sorry

🔥 Exception or Error

$ bazel run //:gazelle                                
INFO: Invocation ID: 2bd54e55-b45f-4f5e-871f-df99e91d5daa
INFO: Analyzed target //:gazelle (37 packages loaded, 713 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
  bazel-bin/gazelle-runner.bash
  bazel-bin/gazelle
INFO: Elapsed time: 0.364s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/gazelle
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_sienna/16dcdf3abbda1ef8268213b48b0911a1/execroot/veridian/bazel-out/darwin_arm64-fastbuild/bin/gazelle.runfiles/rules_python_gazelle_plugin/python/parse.py", line 106, in <module>
    exit(main(sys.stdin, sys.stdout))
  File "/private/var/tmp/_bazel_sienna/16dcdf3abbda1ef8268213b48b0911a1/execroot/veridian/bazel-out/darwin_arm64-fastbuild/bin/gazelle.runfiles/rules_python_gazelle_plugin/python/parse.py", line 91, in main
    outputs.append(parse(repo_root, rel_package_path, filenames[0]))
  File "/private/var/tmp/_bazel_sienna/16dcdf3abbda1ef8268213b48b0911a1/execroot/veridian/bazel-out/darwin_arm64-fastbuild/bin/gazelle.runfiles/rules_python_gazelle_plugin/python/parse.py", line 66, in parse
    content = file.read()
  File "/private/var/tmp/_bazel_sienna/16dcdf3abbda1ef8268213b48b0911a1/external/python_aarch64-apple-darwin/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 64: invalid start byte
gazelle: ERROR: failed to parse: read |0: file already closed

🌍 Your Environment

Operating System:

image

Output of bazel version:

Bazelisk version: development
Build label: 6.2.1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 2 17:00:10 2023 (1685725210)
Build timestamp: 1685725210
Build timestamp as int: 1685725210

Rules_python version:

v0.24.0

Anything else relevant?

N/A

@AdilRas
Copy link

AdilRas commented Dec 29, 2023

Were you able to solve this error? I am also getting this.

@siennathesane
Copy link
Author

IIRC I downgraded, but I don't remember, sorry!

github-merge-queue bot pushed a commit that referenced this issue May 20, 2024
Remove gazelle plugin's python deps and make it hermetic. No more
relying on the system interpreter.

Use TreeSitter to parse Python code and use
https://github.com/pypi/stdlib-list to determine whether a module is in
std lib.

Fixes #1825
Fixes #1599
Related #1315
@aignas aignas added the gazelle Gazelle plugin related issues label Jun 4, 2024
@aignas aignas closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gazelle Gazelle plugin related issues
Projects
None yet
Development

No branches or pull requests

3 participants