Skip to content

Commit

Permalink
Patch #449 to use ANSIBLE_COLLECTIONS_PATH
Browse files Browse the repository at this point in the history
Fixes: #449
  • Loading branch information
ssbarnea committed Jan 23, 2025
1 parent 709cea0 commit cdf532f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __init__(
self.max_retries = max_retries
self.environ = environ or os.environ.copy()
if "ANSIBLE_COLLECTIONS_PATHS" in self.environ:
msg = "ANSIBLE_COLLECTIONS_PATHS was detected, replace it with ANSIBLE_COLLECTION_PATH to continue."
msg = "ANSIBLE_COLLECTIONS_PATHS was detected, replace it with ANSIBLE_COLLECTIONS_PATH to continue."
raise RuntimeError(msg)
self.plugins = Plugins(runtime=self)
self.verbosity = verbosity
Expand Down Expand Up @@ -507,7 +507,7 @@ def install_collection(
cpaths: list[str] = self.config.collections_paths
if destination and str(destination) not in cpaths:
# we cannot use '-p' because it breaks galaxy ability to ignore already installed collections, so
# we hack ANSIBLE_COLLECTION_PATH instead and inject our own path there.
# we hack ANSIBLE_COLLECTIONS_PATH instead and inject our own path there.
# pylint: disable=no-member
cpaths.insert(0, str(destination))
cmd.append(f"{collection}")
Expand All @@ -516,7 +516,7 @@ def install_collection(
process = self.run(
cmd,
retry=True,
env={**self.environ, "ANSIBLE_COLLECTION_PATH": ":".join(cpaths)},
env={**self.environ, "ANSIBLE_COLLECTIONS_PATH": ":".join(cpaths)},
)
if process.returncode != 0:
msg = f"Command {' '.join(cmd)}, returned {process.returncode} code:\n{process.stdout}\n{process.stderr}"
Expand Down
2 changes: 1 addition & 1 deletion test/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,6 @@ def test_runtime_exception(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("ANSIBLE_COLLECTIONS_PATHS", "foo")
with pytest.raises(
RuntimeError,
match=r"ANSIBLE_COLLECTIONS_PATHS was detected, replace it with ANSIBLE_COLLECTION_PATH to continue.",
match=r"ANSIBLE_COLLECTIONS_PATHS was detected, replace it with ANSIBLE_COLLECTIONS_PATH to continue.",
):
Runtime()

0 comments on commit cdf532f

Please sign in to comment.