@@ -270,6 +270,7 @@ def _patch_collection_paths(self) -> None:
270270 ansible-core and ade behavior and trick ansible-galaxy to install
271271 default to the venv site-packages location (isolation).
272272 """
273+ # ansible-core normal precedence is: adjacent, local paths, configured paths, site paths
273274 collections_paths : list [str ] = self .config .collections_paths .copy ()
274275 if self .config .collections_scan_sys_path :
275276 for path in sys .path :
@@ -280,15 +281,13 @@ def _patch_collection_paths(self) -> None:
280281 collections_paths .append ( # pylint: disable=E1101
281282 path ,
282283 )
283- # When inside a venv, we also add the site-packages to the top of the
284- # collections path because this is the first place where ansible-core
284+ # When inside a venv, we also add the site-packages to the end of the
285+ # collections path because this is the last place where ansible-core
285286 # will look for them. This also ensures that when calling ansible-galaxy
286- # to install content, it will be installed in the venv site-packages instead
287- # of altering the user configuration. Matches behavior of ADE and
288- # ensures isolation.
287+ # to install content.
289288 for path in reversed (site .getsitepackages ()):
290289 if path not in collections_paths :
291- collections_paths .insert ( 0 , path )
290+ collections_paths .append ( path )
292291
293292 if collections_paths != self .config .collections_paths :
294293 _logger .info (
0 commit comments