A bit of an edge case, but thought worth sharing -...
# development
f
A bit of an edge case, but thought worth sharing -- environment variables won't be interpolated unless Pants bootstraps itself first? Docs page
Copy code
pants.toml
-pants_version = "2.12.0"
+pants_version = "%(env.MY_FAVOURITE_PANTS_VERSION)s"
Copy code
$ MY_FAVOURITE_PANTS_VERSION="2.12.0" ./pants version
./pants: line 132: [[: %(env: syntax error: operand expected (error token is "%(env")
....
b
The
pants_version
line is special. The
./pants
script parses it out: https://github.com/pantsbuild/setup/blob/eb887ad5fd80766214e8c38102a5bc92d1342beb/pants#L132
Feel free to open an issue or PR to make that less of an ouch
f
yep, yep. Quite expected 🙂 thought to share for extra awareness in case anyone tried to parametrise the Pants version 😄
b
If the Pants launcher was instead an executable, we could be more clever. Kinda like
bazelisk
for Bazel
👍 1
f
oh interesting. If I remove
pants_version
from the
[GLOBAL]
altogether:
Copy code
./pants version --pants-version="2.12.0"
Please explicitly specify the `pants_version` in your `pants.toml` under the `[GLOBAL]` scope.
See <https://pypi.org/project/pantsbuild.pants/#history> for all released versions
and <https://www.pantsbuild.org/docs/installation> for more instructions.
and if I set some bogus version it's being used despite having an env var set:
Copy code
$ PANTS_VERSION="2.12.0" ./pants version 
Bootstrapping Pants using /home/homeuser/.pyenv/versions/3.9.13/envs/cheeseshop/bin/python3.9
Installing pantsbuild.pants==9.99.9  into a virtual environment at /home/homeuser/.cache/pants/setup/bootstrap-Linux-x86_64/9.99.9 _py39
but the docs do mention this option