hey team. An interesting behaviour worth sharing —...
# general
f
hey team. An interesting behaviour worth sharing — a MacOS user runs
./pants run project/script.py
. The user has a Python 3.7 interpreter accessible on the
PATH
which Pants finds but reports it needs Python 3.8 to run this particular script in the monorepo. User makes an installation of Python 3.8 version (which replaces the Python 3.7 on
/usr/bin/python3
) and re-runs
./pants run project/script.py
. Pants can’t still find the new interpreter. Note that user has been successfully able to work with the Pants monorepo when running targets that required Python 3.7 version. What has helped:
$ rm -rf .pids && rm -rf .pants.d
in the local monorepo directory and restart computer, but the issue persists.
$ rm -rf /Users/user.name/.cache/pants
and restart. Pants is now able to find the new Python interpreter. Could it be that Pants caches the
/usr/bin/python3
version so that any subsequent changes to that shim won’t have any effect unless the
/Users/user.name/.cache/pants
is removed?
The full message:
Copy code
% ./pants run project/script.py
16:06:57.94 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/Users/user.name/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.tK3DqZ/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner
    return self._perform_run(goals)
  File "/Users/user.name/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.tK3DqZ/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/user.name/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.tK3DqZ/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 190, in _perform_run_body
    return self.graph_session.run_goal_rules(
  File "/Users/user.name/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.tK3DqZ/install/lib/python3.9/site-packages/pants/init/engine_initializer.py", line 135, in run_goal_rules
    exit_code = self.scheduler_session.run_goal_rule(
  File "/Users/user.name/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.tK3DqZ/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 533, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/user.name/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.tK3DqZ/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 501, in _raise_on_error
    raise ExecutionError(

Exception message: 1 Exception encountered:

  ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython==3.8.*,>=3.6' failed with exit code 102.
stdout:

stderr:
Could not find a compatible interpreter.

Examined the following interpreters:
1.) /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python CPython==2.7.16
2.)                                                                                    /usr/bin/python3 CPython==3.7.3

No interpreter compatible with the requested constraints was found:
  Version matches CPython==3.8.*,>=3.6




(Use --print-stacktrace for more error details and/or --no-process-execution-local-cleanup to inspect chroots and/or -ldebug for more logs. See <https://www.pantsbuild.org/v2.6/docs/troubleshooting> for common issues. Consider reaching out for help: <https://www.pantsbuild.org/v2.6/docs/getting-help.>)
e
Ok. Well, that's a bug. Presumably you have no
/usr/bin/python3.x
and just
/usr/bin/python3
. If you had the typical `/usr/bin/python{,<major>,<major>.<minor>}`the bug would be masked and evrything would have just worked. I'll file here shortly.
f
Presumably you have no 
/usr/bin/python3.x
 and just 
/usr/bin/python3
That’s right, there is only
/usr/bin/python3
. It’s arguably not a common case to use Python shim coming from XCode (I guess people would more often use
pyenv
on MacOS, but I could be wrong), and updating it in place, so please judge on the amount of time needed to fix appropriately 🙂
e
Well, I have a special personal dislike for macOS and its shenanigans, but this is important to fix. I've just freed up an old mac laptop from the need to run Linux; so I'll get that set up with macOS to repro and fix.
I think this is the same issue tracked here: https://github.com/pantsbuild/pex/issues/1386 I'll take that over and see if I can figure this out.
🙌 1