@@ -661,7 +661,7 @@ def prepare_environment( # noqa: C901
661661 role_name_check : int = 0 ,
662662 ) -> None :
663663 """Make dependencies available if needed."""
664- destination : Path | None = None
664+ destination : Path = self . cache_dir / "collections"
665665 if required_collections is None :
666666 required_collections = {}
667667
@@ -695,7 +695,6 @@ def prepare_environment( # noqa: C901
695695 destination = destination ,
696696 )
697697
698- destination = self .cache_dir / "collections"
699698 for name , min_version in required_collections .items ():
700699 self .install_collection (
701700 f"{ name } :>={ min_version } " ,
@@ -704,22 +703,21 @@ def prepare_environment( # noqa: C901
704703
705704 galaxy_path = self .project_dir / "galaxy.yml"
706705 if (galaxy_path ).exists ():
707- if destination :
708- # while function can return None, that would not break the logic
709- colpath = Path (
710- f"{ destination } /ansible_collections/{ colpath_from_path (self .project_dir )} " ,
711- )
712- if colpath .is_symlink ():
713- if os .path .realpath (colpath ) == str (Path .cwd ()):
714- _logger .warning (
715- "Found symlinked collection, skipping its installation." ,
716- )
717- return
706+ # while function can return None, that would not break the logic
707+ colpath = Path (
708+ f"{ destination } /ansible_collections/{ colpath_from_path (self .project_dir )} " ,
709+ )
710+ if colpath .is_symlink ():
711+ if os .path .realpath (colpath ) == str (Path .cwd ()):
718712 _logger .warning (
719- "Collection is symlinked, but not pointing to %s directory, so we will remove it." ,
720- Path .cwd (),
713+ "Found symlinked collection, skipping its installation." ,
721714 )
722- colpath .unlink ()
715+ return
716+ _logger .warning (
717+ "Collection is symlinked, but not pointing to %s directory, so we will remove it." ,
718+ Path .cwd (),
719+ )
720+ colpath .unlink ()
723721
724722 # molecule scenario within a collection
725723 self .install_collection_from_disk (
0 commit comments