fresh-cat-90827
03/18/2023, 1:57 PMrule_runner.run_goal_rule
and am getting
E File "/var/tmp/username-cache/pants/named_caches/pex_root/venvs/s/dacfc6a3/venv/lib64/python3.9/site-packages/pants/core/util_rules/system_binaries.py", line 646, in find_python
E raise BinaryNotFoundError(
E pants.core.util_rules.system_binaries.BinaryNotFoundError: Was not able to locate a Python interpreter to execute rule code.
E
E Please ensure that Python is available in one of the locations identified by `[python-bootstrap].search_path`, which currently expands to:
E
E ()
This error was seen previously by others (1, 2) and the resolution was to use env_inherit
when setting up the rule runner. This doesn't help me, however.
I run this and can confirm I run this and can confirm there are plenty of python interpreters there. I'm setting the PATH just to make sure it's actually being set and read.
$ PATH="/usr/bin/" ./pants test pants-plugins/internal_plugins/foo/foo_test.py --test-debug
(Pdb) rule_runner.environment
CompleteEnvironmentVars({'PATH': '/usr/bin/'})
E Engine traceback:
E in select
E ..
E in internal_plugins.foo.foobar.export_dependencies
E `my-goal` goal
E in pants.engine.internals.graph.resolve_targets
E ..
E in pants.engine.internals.graph.resolve_unexpanded_targets
E ..
E in pants.engine.internals.graph.resolve_dependencies
E Resolve direct dependencies of target - project/moduleA.py
E in pants.backend.python.dependency_inference.rules.infer_python_dependencies_via_source
E Inferring Python dependencies by analyzing source
E in pants.backend.python.dependency_inference.parse_python_dependencies.parse_python_dependencies
E ..
E in pants.backend.python.util_rules.pex.find_interpreter
E Find Python interpreter for constraints - CPython<4,>=3.7
E in pants.engine.process.fallible_to_exec_result_or_raise
E ..
E in pants.backend.python.util_rules.pex_cli.setup_pex_cli_process
E ..
E in pants.backend.python.util_rules.pex_environment.find_pex_python
E Prepare environment for running PEXes
E in pants.core.util_rules.system_binaries.find_python
E Finding a `python` binary
E
E Traceback (most recent call last):
E File "/var/tmp/username-cache/pants/named_caches/pex_root/venvs/s/dacfc6a3/venv/lib64/python3.9/site-packages/pants/engine/internals/selectors.py", line 593, in native_engine_generator_send
E res = func.send(arg)
E File "/var/tmp/username-cache/pants/named_caches/pex_root/venvs/s/dacfc6a3/venv/lib64/python3.9/site-packages/pants/core/util_rules/system_binaries.py", line 646, in find_python
E raise BinaryNotFoundError(
E pants.core.util_rules.system_binaries.BinaryNotFoundError: Was not able to locate a Python interpreter to execute rule code.
E
E Please ensure that Python is available in one of the locations identified by `[python-bootstrap].search_path`, which currently expands to:
E
E ()
@pytest.fixture
def rule_runner() -> RuleRunner:
rule_runner = RuleRunner(
rules=[*rules(), *core_rules(), *python_rules(), *external_tool.rules(),],
target_types=[PythonSourcesGeneratorTarget])
rule_runner.set_options([], env_inherit={"PATH"})
return rule_runner
witty-crayon-22786
03/20/2023, 4:10 PMset_options
is side-effecting, there are some other methods which can override what has been set… run_goal_rule
has it’s own env_inherit
argument, iirc.