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

average-vr-56795

04/09/2020, 3:33 PM
@hundreds-father-404 I just ran into a fun filespecs thing…
./pants list dir/foo
fails if either: 1. Your global
pants_ignore
contains a pattern which matches
dir/foo
2.
foo
is actually
BUILD
file and your global
build_ignore
contains a pattern which matches that BUILD file
We ran into this because we use
git diff --name-only master | xargs ./pants lint
now, and assume that pants will ignore anything that should be ignored
Do we need to change our linter script to also apply pants’s filtering logic? Or should pants ignore these things?
w

witty-crayon-22786

04/09/2020, 3:36 PM
what's the actual error?
a

average-vr-56795

04/09/2020, 3:37 PM
Copy code
Exception message: 1 Exception encountered:
Computing Select((<pants.base.specs.FilesystemSpecs object at 0x10eda01d0>, <pants.engine.console.Console object at 0x10edb64e0>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32fa20>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='83272eaa3d4eac1153a92834c4d0dc602aefcecf', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32f748>)))))), List)
  Computing Task(pants.rules.core.list_targets:35:list_targets(), (<pants.base.specs.FilesystemSpecs object at 0x10eda01d0>, <pants.engine.console.Console object at 0x10edb64e0>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32fa20>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='83272eaa3d4eac1153a92834c4d0dc602aefcecf', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32f748>)))))), List, false)
    Computing Task(pants.engine.build_files:261:remove_provenance(), (<pants.base.specs.FilesystemSpecs object at 0x10eda01d0>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32fa20>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='83272eaa3d4eac1153a92834c4d0dc602aefcecf', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32f748>)))))), BuildFileAddresses, true)
      Computing Task(pants.engine.legacy.graph:730:provenanced_addresses_from_filesystem_specs(), (<pants.base.specs.FilesystemSpecs object at 0x10eda01d0>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32fa20>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='83272eaa3d4eac1153a92834c4d0dc602aefcecf', values=_IniValues(parser=<configparser.ConfigParser object at 0x10b32f748>)))))), ProvenancedBuildFileAddresses, true)
        Throw(No owning targets could be found for the file `dir/BUILD`.

Please check that there is a BUILD file in `dir` with a target whose `sources` field includes `dir/BUILD`. See <https://www.pantsbuild.org/build_files.html.>)
          Traceback (most recent call last):
            File "/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/lib/python3.6/site-packages/pants/engine/native.py", line 487, in extern_generator_send
              res = c.from_value(func[0]).send(c.from_value(arg[0]))
            File "/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/lib/python3.6/site-packages/pants/engine/legacy/graph.py", line 761, in provenanced_addresses_from_filesystem_specs
              raise ResolveError(msg)
          pants.engine.mapper.ResolveError: No owning targets could be found for the file `dir/BUILD`.

          Please check that there is a BUILD file in `dir` with a target whose `sources` field includes `dir/BUILD`. See <https://www.pantsbuild.org/build_files.html>.
Different errors; for the
build_ignore
case:
For the `pants_ignore`:
Copy code
Exception message: 1 Exception encountered:
Computing Select((<pants.base.specs.FilesystemSpecs object at 0x1089fa908>, <pants.engine.console.Console object at 0x10d3022e8>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984aa58>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='d83fe3d2638f688317c002d3b4394d0b1aa01b9e', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984a7b8>)))))), List)
  Computing Task(pants.rules.core.list_targets:35:list_targets(), (<pants.base.specs.FilesystemSpecs object at 0x1089fa908>, <pants.engine.console.Console object at 0x10d3022e8>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984aa58>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='d83fe3d2638f688317c002d3b4394d0b1aa01b9e', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984a7b8>)))))), List, false)
    Computing Task(pants.engine.build_files:261:remove_provenance(), (<pants.base.specs.FilesystemSpecs object at 0x1089fa908>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984aa58>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='d83fe3d2638f688317c002d3b4394d0b1aa01b9e', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984a7b8>)))))), BuildFileAddresses, true)
      Computing Task(pants.engine.legacy.graph:730:provenanced_addresses_from_filesystem_specs(), (<pants.base.specs.FilesystemSpecs object at 0x1089fa908>, OptionsBootstrapper(env_tuples=(), bootstrap_args=(), args=('/Users/dwagnerhall/.cache/pants/setup/bootstrap-Darwin-x86_64/1.25.0_py36/bin/pants', 'list', 'dir/BUILD'), config=_ChainedConfig(chained_configs=(_SingleFileConfig(config_path='/Users/dwagnerhall/.pants.rc', content_digest='c97b6ac3cdfaf1fe047c2c66e823888ff5082bd3', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984aa58>)), _SingleFileConfig(config_path='/Users/dwagnerhall/tmp/pantsrepro/pants.ini', content_digest='d83fe3d2638f688317c002d3b4394d0b1aa01b9e', values=_IniValues(parser=<configparser.ConfigParser object at 0x10984a7b8>)))))), ProvenancedBuildFileAddresses, true)
        Computing Snapshot(PathGlobs(globs=('dir/BUILD',), glob_match_error_behavior=<GlobMatchErrorBehavior.error: 'error'>, conjunction=<GlobExpansionConjunction.all_match: 'all_match'>, description_of_origin='file arguments'))
          Throw(Unmatched glob from file arguments: "dir/BUILD")
            Traceback (no traceback):
              <pants native internals>
            Exception: Unmatched glob from file arguments: "dir/BUILD"
w

witty-crayon-22786

04/09/2020, 3:37 PM
re: unmatched globs, the linter at Twitter passes the option to ignore them
so that's probably from something else you've written
re: the first error: definitely a bug.
ooor. actually. i think those are both possible to skip via options.
a

average-vr-56795

04/09/2020, 3:38 PM
I see the
--owners-not-found-behavior=ignore
flag being passed. I still see the error.
w

witty-crayon-22786

04/09/2020, 3:39 PM
so what was the full command?
a

average-vr-56795

04/09/2020, 3:39 PM
Let me publish my repo 🙂
Running
./pants --owners-not-found-behavior=ignore list dir/BUILD
fails when any one or two of the config settings in pants.ini are in effect
I take it back, looks like the
build_ignore
works fine, but the
pants_ignore
doesn’t
👍 1
Updated the repo with a repro in the README.md - no file edits needed, pants.ini empty 🙂
w

witty-crayon-22786

04/09/2020, 4:01 PM
thanks a lot
h

hundreds-father-404

04/09/2020, 4:05 PM
Interesting. That would mean
--owner-of
had this same bug, but yeah sounds like a bug