I am seeing the following error with WIP PR <https...
# development
f
I am seeing the following error with WIP PR https://github.com/pantsbuild/pants/pull/17914:
Copy code
DifferingFamiliesError: Expected AddressMaps to share the same parent directory 'cgo', but received: '/BUILD._go_sdk'
I was trying to run
./pants_from_sources dependencies cgo/cgotest2::
in my Go backend testing repo https://github.com/tdyas/pants-go-testing. It seems like the synthetic
_go_sdk
target was being created in the subdirectory and not the root of the repo as expected. Thoughts?
πŸ‘€ 1
βœ… 1
The error also occurs if I change
/BUILD._go_sdk
to `BUILD._go_sdk`(withou the
/
).
c
I’ll take a minute to go through that PR πŸ™‚
Ah, any reason to not use the
SyntheticAddressMaps.for_targets_request()
constructor? Example: https://github.com/pantsbuild/pants/blob/2a6640cd7b0918f08ab28c28b8f3b9ee9a90c60f/src/python/pants/backend/python/goals/lockfile.py#L301-L311
I think you miss prepending the path from the input
request
type on your generated
BUILD._go_sdk
file..
so, something like:
Copy code
return SyntheticAddressMaps([
        SyntheticAddressMap.create(os.path.join(request.path, "BUILD._go_sdk"), [TargetAdaptor(GoSdkTarget.alias, name="default_go_sdk")])
    ])
f
an earlier iteration was using it. same problem. prepending request.path seems wrong. I want a singleton instance of the
_go_sdk
target type, not a copy of it in every directory.
c
Ah, then you don’t want the
path: str = SyntheticTargetsRequest.REQUEST_TARGETS_PER_DIRECTORY
but the other one
path: str = SyntheticTargetsRequest.SINGLE_REQUEST_FOR_ALL_TARGETS
f
I think I just copy-pasta'ed that. πŸ€¦β€β™‚οΈ
😝 1
c
could be worth while to read the docstring of
SyntheticTargetsRequest
in synthetic_targets.py for a minute, it goes over that in detail πŸ™‚
but also asking here is perfectly fine, of course πŸ™‚
f
I stupidly had
spec_paths_request = SyntheticTargetsRequest.SINGLE_REQUEST_FOR_ALL_TARGETS
and then copy pasta'ed the other wrong line when that first attempt obviously failed to typecheck ...
if this was tennis, I just gave up a point because ... double fault
and did this after reading the doc string ... πŸ™‚
🫠 1
c
we’ve got so many details flying around, bound to happen occasionally πŸ˜‰
f
dep inference works now for it:
Copy code
% ./pants_from_sources --print-stacktrace dependencies cgo/life
//:default_go_sdk#flag
//:default_go_sdk#fmt
cgo/life/pkg:pkg
cgo/life:life
πŸ™Œ 1