diff --git a/src/ansible_compat/runtime.py b/src/ansible_compat/runtime.py index a7b9acab..ddc7029b 100644 --- a/src/ansible_compat/runtime.py +++ b/src/ansible_compat/runtime.py @@ -395,7 +395,9 @@ def run( # ruff: disable=PLR0913 env["ANSIBLE_VERBOSE_TO_STDERR"] = "True" if set_acp: - env["ANSIBLE_COLLECTIONS_PATH"] = ":".join(self.config.collections_paths) + env["ANSIBLE_COLLECTIONS_PATH"] = ":".join( + list(dict.fromkeys(self.config.collections_paths)), + ) for _ in range(self.max_retries + 1 if retry else 1): result = run_func( @@ -636,6 +638,7 @@ def prepare_environment( # noqa: C901 if required_collections is None: required_collections = {} + self._prepare_ansible_paths() # first one is standard for collection layout repos and the last two # are part of Tower specification # https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#ansible-galaxy-support @@ -646,8 +649,6 @@ def prepare_environment( # noqa: C901 file_path = self.project_dir / req_file self.install_requirements(file_path, retry=retry, offline=offline) - self._prepare_ansible_paths() - if not install_local: return