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

fast-nail-55400

01/03/2023, 11:10 PM
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

curved-television-6568

01/03/2023, 11:13 PM
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

fast-nail-55400

01/03/2023, 11:22 PM
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

curved-television-6568

01/03/2023, 11:22 PM
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

fast-nail-55400

01/03/2023, 11:23 PM
I think I just copy-pasta'ed that. πŸ€¦β€β™‚οΈ
😝 1
c

curved-television-6568

01/03/2023, 11:24 PM
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

fast-nail-55400

01/03/2023, 11:26 PM
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

curved-television-6568

01/03/2023, 11:32 PM
we’ve got so many details flying around, bound to happen occasionally πŸ˜‰
f

fast-nail-55400

01/03/2023, 11:32 PM
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