narrow-vegetable-37489
04/01/2022, 11:15 AMNo module named 'pants.backend.experimental.codegen.protobuf.go'
. Is it because it's missing from here perhaps?fast-nail-55400
04/01/2022, 11:56 AMfast-nail-55400
04/01/2022, 12:21 PMfast-nail-55400
04/01/2022, 12:21 PMPANTS_SHA
mechanism in the ./pants
script.hallowed-plastic-91664
04/02/2022, 7:28 PMhallowed-plastic-91664
04/02/2022, 7:32 PMPANTS_SHA=529979dc04fca1f5aea1ea0cb23ab514f11abe32 ./pants package ::
14:30:56.75 [WARN] Unmatched globs from pkg/model:model0's `sources` field: ["pkg/model/*.go", "pkg/model/*.s"]
Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.12/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
14:30:56.75 [ERROR] Completed: Set up Go compilation request - <http://github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model|github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model> failed (exit code 1).
failed to read directory pkg/model: open pkg/model: no such file or directory
14:30:56.75 [ERROR] 1 Exception encountered:
Exception: Failed to determine metadata to compile main:
failed to read directory pkg/model: open pkg/model: no such file or directory
fast-nail-55400
04/04/2022, 2:19 PM143056.75 [WARN] Unmatched globs from pkg/model:model0'sDid you remove the correspondingfield: [“pkg/model/*.go”, “pkg/model/*.s”]sources
go_package
?hallowed-plastic-91664
04/04/2022, 10:28 PMPANTS_SHA=529979dc04fca1f5aea1ea0cb23ab514f11abe32 ./pants package ::
17:27:54.39 [INFO] Initializing scheduler...
17:27:54.45 [INFO] Scheduler initialized.
17:27:56.67 [ERROR] Completed: Compile with Go - main failed (exit code 1).
./cmd/client/main.go:9:5: could not import <http://github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model|github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model> (open : no such file or directory)
17:27:56.67 [ERROR] Completed: Compile with Go - main failed (exit code 1).
./cmd/server/main.go:10:5: could not import <http://github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model|github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model> (open : no such file or directory)
17:27:56.67 [ERROR] 1 Exception encountered:
Exception: Failed to compile main:
./cmd/client/main.go:9:5: could not import <http://github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model|github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model> (open : no such file or directory)
i removed it, still the samefast-nail-55400
04/04/2022, 11:33 PMfast-nail-55400
04/05/2022, 6:11 PMhallowed-plastic-91664
04/05/2022, 10:16 PMhallowed-plastic-91664
04/05/2022, 10:19 PMPANTS_SHA=529979dc04fca1f5aea1ea0cb23ab514f11abe32 ./pants package ::
It will produce that outputfast-nail-55400
04/06/2022, 12:34 AMoption go_package = "pkg/model";
— make that be the full import path, so option go_package = "<http://github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model|github.com/xyzst/go-mono-repo-with-pants-sample/pkg/model>";
fast-nail-55400
04/06/2022, 2:02 AM22:02:05.20 [ERROR] Completed: Compile with Go - main failed (exit code 1).
./cmd/client/main.go:31:10: undefined: model.NewGreeterClient
22:02:05.20 [ERROR] Completed: Compile with Go - main failed (exit code 1).
./cmd/server/main.go:20:5: undefined: model.UnimplementedGreeterServer
./cmd/server/main.go:36:5: undefined: model.RegisterGreeterServer
22:02:05.20 [ERROR] 1 Exception encountered:
Exception: Failed to compile main:
./cmd/client/main.go:31:10: undefined: model.NewGreeterClient
fast-nail-55400
04/06/2022, 2:07 AMgrpc=True
on protobuf_sources
fast-nail-55400
04/06/2022, 2:08 AMhallowed-plastic-91664
04/06/2022, 3:30 PMfast-nail-55400
04/06/2022, 3:51 PMoption go_package = "pkg/model"
should have worked as written? i.e., does protoc
prepend the import path from the go.mod at all?fast-nail-55400
04/06/2022, 3:51 PMprotoc
knows anything about go.mod’s)hallowed-plastic-91664
04/06/2022, 5:53 PMprotoc --go_out=./ --go_opt=paths=source_relative \
--go-grpc_out=./ --go-grpc_opt=paths=source_relative \
./pkg/model/hello_world.proto
hallowed-plastic-91664
04/06/2022, 5:56 PMgo build cmd/client/main.go -o client
hallowed-plastic-91664
04/06/2022, 5:57 PMhallowed-plastic-91664
04/06/2022, 5:57 PMnarrow-vegetable-37489
04/11/2022, 4:11 PMoption go_package
specifies I get the following error (as expected) when running `./pants run path/to/:bin`:
Exception: Failed to compile main:
./path/to/file.go:3:16: could not import <http://example.com/invalid/path/to/generated/proto|example.com/invalid/path/to/generated/proto> (open : no such file or directory)
When I fix this path however to what's in option go_package
, I get this interesting error when running `./pants run path/to/:bin`:
KeyError: 'The target `python_requirement(address="vendor#grpcio", dependencies=(\'vendor/requirements.txt\',), description=None, modules=(\'grpc\',), requirements=(<pants.backend.python.pip_requirement.PipRequirement object at 0x105877d30>,), resolve=None, tags=None, type_stub_modules=None)` does not have a field `ProtobufSourceField`. Before calling `my_tgt[ProtobufSourceField]`, call `my_tgt.has_field(ProtobufSourceField)` to filter out any irrelevant Targets or call `my_tgt.get(ProtobufSourceField)` to use the default Field value.'
./pants export-codegen
does work, so seems like the Go dependency inference is the cause of it rather than the code generation itself. Any way to further debug this?fast-nail-55400
04/11/2022, 4:31 PMoption go_package
set to? full import path?fast-nail-55400
04/11/2022, 4:33 PM--print-stacktrace
so we can see what code is triggered that KeyErrornarrow-vegetable-37489
04/11/2022, 4:50 PMoption go_package
is full import, yes. It's the exact path the .proto-files are in, but with the repository's URL prepended.
Engine traceback:
in select
in pants.core.goals.run.run
in pants.backend.go.goals.run_binary.create_go_binary_run_request (golang/cmd/planner:bin)
in pants.backend.go.goals.package_binary.package_go_binary (golang/cmd/planner:bin)
in pants.backend.go.util_rules.build_pkg.required_built_go_package (golang/cmd/planner:planner)
in pants.backend.go.util_rules.build_pkg.build_go_package (golang/cmd/planner:planner)
in pants.backend.go.util_rules.build_pkg_target.required_build_go_package_request (golang/cmd/planner:planner)
in pants.backend.go.util_rules.build_pkg_target.setup_build_go_package_target_request (golang/cmd/planner:planner)
in pants.backend.go.util_rules.build_pkg_target.setup_build_go_package_target_request (path/to/some/protobuf/file.proto)
in pants.backend.codegen.protobuf.go.rules.setup_build_go_package_request_for_protobuf
in pants.backend.codegen.protobuf.go.rules.setup_full_package_build_request
Traceback (most recent call last):
File "/Users/jyggen/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0rc2_py39/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 705, in native_engine_generator_send
res = func.send(arg)
File "/Users/jyggen/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0rc2_py39/lib/python3.9/site-packages/pants/backend/codegen/protobuf/go/rules.py", line 198, in setup_full_package_build_request
SourceFilesRequest(
File "/Users/jyggen/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0rc2_py39/lib/python3.9/site-packages/pants/util/meta.py", line 130, in new_init
prev_init(self, *args, **kwargs)
File "/Users/jyggen/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0rc2_py39/lib/python3.9/site-packages/pants/core/util_rules/source_files.py", line 42, in __init__
self.sources_fields = tuple(sources_fields)
File "/Users/jyggen/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0rc2_py39/lib/python3.9/site-packages/pants/backend/codegen/protobuf/go/rules.py", line 199, in <genexpr>
sources_fields=(tgt[ProtobufSourceField] for tgt in transitive_targets.closure),
File "/Users/jyggen/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0rc2_py39/lib/python3.9/site-packages/pants/engine/target.py", line 483, in __getitem__
raise KeyError(
KeyError: 'The target `python_requirement(address="vendor#grpcio", dependencies=(\'vendor/requirements.txt\',), description=None, modules=(\'grpc\',), requirements=(<pants.backend.python.pip_requirement.PipRequirement object at 0x10f3b3100>,), resolve=None, tags=None, type_stub_modules=None)` does not have a field `ProtobufSourceField`. Before calling `my_tgt[ProtobufSourceField]`, call `my_tgt.has_field(ProtobufSourceField)` to filter out any irrelevant Targets or call `my_tgt.get(ProtobufSourceField)` to use the default Field value.'
fast-nail-55400
04/11/2022, 4:53 PMif tgt.has_Field(ProtobufSourceField)
on the comprehensionfast-nail-55400
04/11/2022, 4:57 PM./pants_from_sources
script)?fast-nail-55400
04/11/2022, 4:57 PMnarrow-vegetable-37489
04/11/2022, 5:00 PMfast-nail-55400
04/11/2022, 5:13 PMpants_from_sources
in some of the Pants example repos, e.g. https://github.com/pantsbuild/example-codegen/blob/main/pants_from_sourcesfast-nail-55400
04/11/2022, 9:41 PMnarrow-vegetable-37489
04/12/2022, 12:30 AMfast-nail-55400
04/12/2022, 12:40 AM