Hi everyome, i have a strange issue using pants wi...
# general
b
Hi everyome, i have a strange issue using pants with my golang repo. I have installed pants version 2.21.0, when i run
pants tailor ::
i always geht the following error:
Copy code
*[main][~/src/go-repo]$ pants tailor ::
13:53:20.06 [INFO] waiting for pantsd to start...
13:53:21.37 [INFO] pantsd started
13:53:21.92 [INFO] Initializing scheduler...
13:53:22.34 [INFO] Scheduler initialized.
13:53:22.58 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IncompleteJSONError: Incomplete JSON content
Any idea what could be wrong? Ah, i am using Go 1.22.4
w
Can you run it with
-ldebug
? Maybe it'll show the file that is causing this
b
umm, maybe, did not recogniize the issue as it is rather old
debug is not very helpful i assue
Copy code
13:59:45.26 [DEBUG] Completed: Determine Go SDK metadata for /usr/bin/go
13:59:45.26 [DEBUG] Completed: Scheduling: Determine Go SDK metadata for /usr/bin/go
13:59:45.26 [DEBUG] Completed: Find Go binary
13:59:45.26 [DEBUG] Completed: Scheduling: Parse apps/sharedenv-vm/go.mod
13:59:45.27 [DEBUG] Completed: Scheduling: Analyze Go module dependencies.
13:59:45.29 [DEBUG] Completed: Scheduling: Ask Go for its available import paths
13:59:45.29 [DEBUG] Completed: Analyze Go standard library packages.
13:59:45.30 [DEBUG] Completed: Download and analyze all third-party Go packages
13:59:45.30 [DEBUG] Completed: Generate `go_third_party_package` targets from `go_mod` target
13:59:45.30 [DEBUG] Completed: Find all sources from input specs
13:59:45.30 [DEBUG] Completed: `tailor` goal
13:59:45.30 [DEBUG] computed 1 nodes in 0.238858 seconds. there are 184 total nodes.
13:59:45.30 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IncompleteJSONError: Incomplete JSON content
when running with
--print-stacktrace
it shows the following:
Copy code
File "/home/sja/.cache/nce/60b513559c7b53eb2acecbd7b8aaaeb942686f3997d07fa77377b51324f58fda/bindings/venvs/2.21.0/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 124, in __await__
    result = yield self
  File "/home/sja/.cache/nce/60b513559c7b53eb2acecbd7b8aaaeb942686f3997d07fa77377b51324f58fda/bindings/venvs/2.21.0/lib/python3.9/site-packages/pants/backend/go/util_rules/import_analysis.py", line 75, in analyze_go_stdlib_packages
    for pkg_json in ijson.items(list_result.stdout, "", multiple_values=True):
  File "/home/sja/.cache/nce/60b513559c7b53eb2acecbd7b8aaaeb942686f3997d07fa77377b51324f58fda/bindings/venvs/2.21.0/lib/python3.9/site-packages/ijson/utils.py", line 55, in coros2gen
    f.send(value)
  File "/home/sja/.cache/nce/60b513559c7b53eb2acecbd7b8aaaeb942686f3997d07fa77377b51324f58fda/bindings/venvs/2.21.0/lib/python3.9/site-packages/ijson/backends/python.py", line 46, in utf8_encoder
    target.close()
  File "/home/sja/.cache/nce/60b513559c7b53eb2acecbd7b8aaaeb942686f3997d07fa77377b51324f58fda/bindings/venvs/2.21.0/lib/python3.9/site-packages/ijson/backends/python.py", line 116, in Lexer
    target.send(EOF)
  File "/home/sja/.cache/nce/60b513559c7b53eb2acecbd7b8aaaeb942686f3997d07fa77377b51324f58fda/bindings/venvs/2.21.0/lib/python3.9/site-packages/ijson/backends/python.py", line 161, in parse_value
    raise common.IncompleteJSONError('Incomplete JSON content')
ijson.common.IncompleteJSONError: Incomplete JSON content
so it seems again related to this ijson stuff
w
Yeah, it's this file: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/go/util_rules/import_analysis.py But, I don't know enough about Go to debug what can cause this.
command=("list", *maybe_race_arg, "-json", "std"),
Does this command make sense, and is it something you could run at the root of your project to see what gets generated?
go list -json std
? And conditionally with
CGO_ENABLED=1
b
seems to be an issue with the my distribution (Tumbleweed), as
go list std
outputs nothing, e.g.
Copy code
*[main][~/src/go-repo/apps/pipeman]$ go list std
go: warning: "std" matched no packages
w
Yeah, so
go list -json
appears to be necessary for ijson to analyze imports If it's related to
go list
(again I've never used Go), then we should at least have a better error
b
ok, it must be somehow related to the Go installation of Tumbleweed. If i download the latest go distribution and set paths manually everything is working as expected. Not an issue of pants anyways
i will investigate further when i have time, thanks for your fast help @wide-midnight-78598
👍 1