0

I'm trying to setup a Java project using Pants in Linux — specifically Arch Linux.

I'm following the documentation to just install it, but I'm always getting an error when running ./pants --version:

$ ./pants --version 
Invalid Python interpreter version for /usr/bin/python3. For `pants_version = "2.12.0"`, Pants requires Python 3.7, 3.8, or 3.9 to run

I do have Python 3.9.9 installed via asdf and activated for the sub-directory in question.

$ python --version 
Python 3.9.9

Moreover, my configuration already have Python 3.x installed as well by default. So even if I disable the asdf version I do have it in the system:

$ python --version
Python 3.10.5

Is there a way to just overcome this issue? I still don't understand why the pants script is unable to discover the Python interpreter. I do really prefer to use the local version that asdf "activates" because any time the system updates it will probably update the version to one that would be incompatible at some point.

x80486
  • 6,627
  • 5
  • 52
  • 111
  • Make sure `/usr/bin/python3` is also pointing to the appropriate version of Python, as that's what the `pants` script seems to be calling. – MattDMo Jul 23 '22 at 14:23
  • Running `/usr/bin/python --version` or `/usr/bin/python3 --version` both yield the same result: `Python 3.10.5`. So I guess this should be fine, right? Still, `Pants` is unable in my system to use it. – x80486 Jul 23 '22 at 14:28
  • Are you sure `pants` is compatible with 3.10? The error message only mentioned 3.7-3.9. – MattDMo Jul 23 '22 at 14:31
  • Not sure for real. I'm not very familiar with Python either, but I would expect a minor version to be compatible with the previous one, but looks like they are very specific with the version numbers in that shell script :/ – x80486 Jul 23 '22 at 14:39

1 Answers1

0

There is an option to overcome this issue in pants.toml:

[python-bootstrap]
search_path = ["<ASDF_LOCAL>", "<PATH>"]

This basically means Pants will first the ASDF interpreter with the version in <BUILD_ROOT>/.tool-versions and then what's in PATH.

More information on this can be found here.

Regardless, the setup process is all too titchy still and the system version must be set as well.

I filed an issue in the Pants repository and that's where I got the help from. I'm just documenting what's there here.

x80486
  • 6,627
  • 5
  • 52
  • 111