gorgeous-winter-99296
05/21/2025, 8:29 PMecho 'python_sources(name="foo")' > BUILD.first
echo 'python_sources(name="foo")' > BUILD.second
pants list :
Errors before 2.25, runs incorrectly after that, assuming your targets differ. In the exact case we had relocated_files
and shell_command
duplicated in two files, and this poor person spent 3-4 hours just not understanding why their edits in one file had no effect at all.wide-midnight-78598
05/21/2025, 8:36 PMwide-midnight-78598
05/21/2025, 8:39 PMfast-nail-55400
05/21/2025, 8:39 PMwide-midnight-78598
05/21/2025, 8:39 PMgorgeous-winter-99296
05/21/2025, 8:39 PMwide-midnight-78598
05/21/2025, 8:40 PMfast-nail-55400
05/21/2025, 8:40 PMwide-midnight-78598
05/21/2025, 8:41 PMgorgeous-winter-99296
05/21/2025, 8:48 PMwide-midnight-78598
05/21/2025, 9:03 PMwide-midnight-78598
05/21/2025, 9:09 PMwide-midnight-78598
05/21/2025, 9:12 PMāŗ scratch/tompants % pants --no-pantsd list src/python/pants/build_graph:
//src/python/pants/build_graph/__init__.py:../../../../all-__init__.py-files
src/python/pants/build_graph:build_graph
src/python/pants/build_graph:foo
src/python/pants/build_graph:tests
src/python/pants/build_graph/__init__.py
src/python/pants/build_graph/__init__.py:foo
src/python/pants/build_graph/address.py
src/python/pants/build_graph/address.py:foo
src/python/pants/build_graph/address_test.py:tests
src/python/pants/build_graph/build_configuration.py
src/python/pants/build_graph/build_configuration.py:foo
src/python/pants/build_graph/build_configuration_test.py:tests
src/python/pants/build_graph/build_file_aliases.py
src/python/pants/build_graph/build_file_aliases.py:foo
src/python/pants/build_graph/build_file_aliases_test.py:tests
src/python/pants/build_graph/subproject_integration_test.py:tests
āŗ scratch/tompants % git checkout e518a82b9a087dc71f977b733d6c073c7e84321c && pants --no-pantsd list src/python/pants/build_graph:
M pants.toml
M src/python/pants/build_graph/BUILD
Previous HEAD position was 333c2392f8 Fix bad `__hash__` implementations. (#21725)
HEAD is now at e518a82b9a resolve Python 3.11 importlib deprecation WARNings (#21712)
...
pants.engine.internals.mapper.DuplicateNameError: A target with name 'foo' is already defined in 'src/python/pants/build_graph/BUILD', but is also defined in 'src/python/pants/build_graph/BUILD.pants'. Because both targets share the same namespace of 'src/python/pants/build_graph', this is not allowed.
gorgeous-winter-99296
05/21/2025, 9:18 PMname_to_path_and_declared_target: dict[str, tuple[str, TargetAdaptor]] = {}
for declared_address_map in declared_address_maps:
for name, target in declared_address_map.name_to_target_adaptor.items():
name_to_path_and_declared_target[name] = (declared_address_map.path, target)
That name clearly isn't unique in this case... There's a validation step in the AddressFamily create function, but the data is already wrong at that point.fast-nail-55400
05/21/2025, 9:20 PMgorgeous-winter-99296
05/21/2025, 9:21 PMfast-nail-55400
05/21/2025, 9:23 PMgorgeous-winter-99296
05/21/2025, 9:30 PMname_to_path_and_declared_target
already contains the name? Maybe not as nice as a separate validation step but a bunch less work.gorgeous-winter-99296
05/21/2025, 9:31 PMwide-midnight-78598
05/21/2025, 9:31 PMfast-nail-55400
05/21/2025, 9:32 PMgorgeous-winter-99296
05/21/2025, 9:33 PMwide-midnight-78598
05/21/2025, 9:34 PMfast-nail-55400
05/21/2025, 9:34 PMBUILD
files in the same directory?fast-nail-55400
05/21/2025, 9:34 PMfast-nail-55400
05/21/2025, 9:35 PMgorgeous-winter-99296
05/21/2025, 9:36 PMfast-nail-55400
05/21/2025, 9:37 PMfast-nail-55400
05/21/2025, 9:38 PMfast-nail-55400
05/21/2025, 9:38 PMfast-nail-55400
05/21/2025, 9:38 PMfast-nail-55400
05/21/2025, 9:40 PMHow do overrides and defaults work?I wonder if we need to check the logic for other "conflicts between
BULD
files" issues.gorgeous-winter-99296
05/21/2025, 9:41 PMsrc/container
. So src/container/BUILD.gcssync
builds our GCS synch sidecar, etc. And this directory contains no defaults and no overrides, since there's no actual things to override on. šgorgeous-winter-99296
05/21/2025, 9:42 PMwide-midnight-78598
05/21/2025, 9:43 PMwide-midnight-78598
05/21/2025, 9:46 PMTo that end, Pantshttps://www.pantsbuild.org/blog/2022/10/26/pants-2-14#less-boilerplate-via-hierarchical-defaults-for-target-field-values I'm curious if that happens on a BUILD file, or directory basis. Never thought about it beforeintroduces `__defaults__`: a mechanism to set the default arguments used for the targets defined in a directory.2.14
gorgeous-winter-99296
05/21/2025, 10:03 PM**parametrize
variant is especially guilty of this. Can't imagine what kind of shenanigans would happen if you had that in two files in one directory, especially affecting the same target types...fast-nail-55400
05/21/2025, 10:15 PMfast-nail-55400
05/21/2025, 10:16 PMfast-nail-55400
05/21/2025, 10:16 PMfast-nail-55400
05/21/2025, 10:42 PMproud-dentist-22844
05/22/2025, 4:06 PM__defaults__
in those dirs though.