Skip to content

Commit

Permalink
Fix python interpreter for scenario init (#4111)
Browse files Browse the repository at this point in the history
When using Pyenv Virtualenv the ANSIBLE_PYTHON_INTERPRETER passed to
run_command is `auto_silent` and does not resolve to the Python
interpreter used by the virtualenv.

Passing instead `sys.executable` seems solving the issue.
  • Loading branch information
dobbi84 authored Jan 25, 2024
1 parent eb010f4 commit c13bbc7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/molecule/command/init/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import json
import logging
import os
import sys

import click

Expand Down Expand Up @@ -95,7 +96,7 @@ def execute(self, action_args=None):
# As ansible fails to find a terminal when run by molecule, we force
# it to use colors.
env["ANSIBLE_FORCE_COLOR"] = "1"
env["ANSIBLE_PYTHON_INTERPRETER"] = "auto_silent"
env["ANSIBLE_PYTHON_INTERPRETER"] = sys.executable
util.run_command(cmd, env=env, check=True)

msg = f"Initialized scenario in {scenario_directory} successfully."
Expand Down

0 comments on commit c13bbc7

Please sign in to comment.