https://pantsbuild.org/ logo
#development
Title
# development
b

bitter-ability-32190

01/19/2023, 3:46 PM
I can't seem to run Pants commands without go installed...
Copy code
$ ./pants check src/python/pants/backend/python/typecheck/mypy/rules.py
...
Traceback (most recent call last):
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/specs_rules.py", line 258, in resolve_addresses_from_specs
...
pants.core.util_rules.system_binaries.BinaryNotFoundError: Cannot find any `go` binaries using the option ...
Full traceback:
Copy code
$ ./pants check src/python/pants/backend/python/typecheck/mypy/rules.py
09:45:53.77 [ERROR] 1 Exception encountered:

Engine traceback:
  in select
    ..
  in pants.core.goals.check.check
    `check` goal
  in pants.engine.internals.specs_rules.filter_targets
    ..
  in pants.engine.internals.graph.resolve_targets
    ..
  in pants.engine.internals.graph.resolve_unexpanded_targets
    ..
  in pants.engine.internals.specs_rules.resolve_addresses_from_specs
    Find targets from input specs

Traceback (most recent call last):
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/specs_rules.py", line 258, in resolve_addresses_from_specs
    includes, ignores = await MultiGet(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 511, in MultiGet
    return await _MultiGet((__arg0, __arg1))
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 167, in __await__
    result = yield self.gets
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/specs_rules.py", line 246, in resolve_addresses_from_raw_specs
    without_file_owners, with_file_owners = await MultiGet(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 511, in MultiGet
    return await _MultiGet((__arg0, __arg1))
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 167, in __await__
    result = yield self.gets
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/specs_rules.py", line 227, in addresses_from_raw_specs_with_only_file_owners
    owners = await Get(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 120, in __await__
    result = yield self
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/graph.py", line 844, in find_owners
    live_candidate_tgts, deleted_candidate_tgts = await MultiGet(live_get, deleted_get)
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 511, in MultiGet
    return await _MultiGet((__arg0, __arg1))
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 167, in __await__
    result = yield self.gets
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/specs_rules.py", line 176, in addresses_from_raw_specs_without_file_owners
    target_parametrizations_list = await MultiGet(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 360, in MultiGet
    return await _MultiGet(tuple(__arg0))
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 167, in __await__
    result = yield self.gets
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/engine/internals/graph.py", line 288, in resolve_target_parametrizations
    all_generated = await MultiGet(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 360, in MultiGet
    return await _MultiGet(tuple(__arg0))
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 167, in __await__
    result = yield self.gets
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/backend/go/target_type_rules.py", line 467, in generate_targets_from_go_sdk
    stdlib_packages, stdlib_packages_race = await MultiGet(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 511, in MultiGet
    return await _MultiGet((__arg0, __arg1))
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 167, in __await__
    result = yield self.gets
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/backend/go/util_rules/import_analysis.py", line 72, in analyze_go_stdlib_packages
    list_result = await Get(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 120, in __await__
    result = yield self
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/backend/go/util_rules/import_analysis.py", line 72, in analyze_go_stdlib_packages
    list_result = await Get(
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 120, in __await__
    result = yield self
  File "/home/josh/work/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/home/josh/work/pants/src/python/pants/backend/go/util_rules/goroot.py", line 69, in setup_goroot
    raise BinaryNotFoundError(
pants.core.util_rules.system_binaries.BinaryNotFoundError: Cannot find any `go` binaries using the option `[golang].go_search_paths`: ['/home/josh/.cache/pants/pants_dev_deps/Linux.x86_64.x86_64.py38.venv/bin', '/home/josh/.local/bin', '/home/josh/.nvm/versions/node/v16.13.0/bin', '/home/josh/.cargo/bin', '/home/josh/.local/bin', '/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/snap/bin']

To fix, please install Go (<https://golang.org/doc/install>) with the version 1.17 or newer (set by `[golang].minimum_expected_version`). Then ensure that it is discoverable via `[golang].go_search_paths`.
p

polite-garden-50641

01/19/2023, 3:49 PM
b

bitter-ability-32190

01/19/2023, 3:51 PM
Looks like
testprojects
is to blame
Or maybe not...
Copy code
build_ignore.add = [
  # Disable Go targets by default so Pants developers do not need Go installed.
  "testprojects/src/go/**",
]
https://github.com/pantsbuild/pants/pull/17973 @witty-crayon-22786 @fast-nail-55400
For now I'll add this to my
.pants.rc
Copy code
[GLOBAL]
backend_packages.remove = [
    "pants.backend.experimental.go",
]
f

fast-nail-55400

01/19/2023, 4:44 PM
There is already a PR to try and fix this but it fails because of rule graph errors.
Since target API is eager
b

bitter-ability-32190

01/19/2023, 4:46 PM
Why do we enable the go backend in our repo anyways? Smoke test?
f

fast-nail-55400

01/19/2023, 4:47 PM
If we make the SDK target explicit (say as a
go_sdk
target type), then users would need to always specify it if they used Go. But we could not specify it for Pants repo. But that’s changing UX for the sake of our convenience.
The solution here is to make target generation on demand / “lazy”
The change added a synthetic target which itself is a target generator.
w

witty-crayon-22786

01/19/2023, 5:46 PM
if it’s possible to make synthetic targets* lazy, then that would be great. but another way to resolve the general issue would be to bootstrap the go runtime by default, rather than requiring that it is installed
b

bitter-ability-32190

01/19/2023, 5:47 PM
I don't want go installed on my machine 😭 😛
w

witty-crayon-22786

01/19/2023, 5:49 PM
you secretly have a JDK “installed”, because Pants uses one of those =P
b

bitter-ability-32190

01/19/2023, 5:50 PM
throw up hands
w

witty-crayon-22786

01/19/2023, 5:50 PM
and installs it automatically into
~/.cache/pants/named_caches/coursier