cool-easter-32542
07/29/2024, 1:12 AMBUILD files in 2.23.0.dev0 and earlier (including all stable releases), but stopped being available in 2.23.0.dev1 with a hard error.
We should either:
1. allow macros with leading underscores
2. do a deprecation cycle to help users update
Reproducer:
cd $(mktemp -d)
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.23.0.dev1"
backend_packages = []
build_file_prelude_globs = ["macros.py"]
EOF
echo 'def _example(): target(name="_example")' > macros.py
echo "_example()" > BUILD
# OKAY: prints //:_example
PANTS_VERSION=2.23.0.dev0 pants list ::
# BUG: error emitted: "MappingError: Failed to parse ./BUILD ... Name '_example' is not defined"
pants list ::
Full from the second `pants list ::`:
11:18:22.56 [ERROR] 1 Exception encountered:
Engine traceback:
in `list` goal
in Find targets from input specs
MappingError: Failed to parse ./BUILD:
ParseError: BUILD:1: Name '_example' is not defined.
If you expect to see more symbols activated in the below list, refer to <https://www.pantsbuild.org/2.23/docs/using-pants/key-concepts/backends> for all available backends to activate.
All registered symbols: ['PANTS_VERSION', '__defaults__', '__dependencies_rules__', '__dependents_rules__', '_lockfile', '_lockfiles', 'archive', 'build_file_dir', 'docker_environment', 'env', 'experimental_workspace_environment', 'experimental_wrap_as_resources', 'file', 'files', 'http_source', 'local_environment', 'parametrize', 'per_platform', 'relocated_files', 'remote_environment', 'resource', 'resources', 'target']
NB. this occurs in practice in my work repo: we have a macro wrapping __dependencies_rules__ that's named to mimic it, and thus starts with __dependencies_rules_....
Pants version
2.23.0.dev1
OS
macOS
Additional info
Comparison: release_2.23.0.dev0...release_2.23.0.dev1
Potential cause (not confirmed!): #21028, beed36c
pantsbuild/pants