diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py index f8c413afd81..6e7301fc5e0 100644 --- a/src/poetry/utils/shell.py +++ b/src/poetry/utils/shell.py @@ -70,7 +70,13 @@ def get(cls) -> Shell: def activate(self, env: VirtualEnv) -> int | None: activate_script = self._get_activate_script() - bin_dir = "Scripts" if WINDOWS else "bin" + if WINDOWS: + bin_path = env.path / "Scripts" + # Python innstalled via msys2 on Windows might produce a POSIX-like venv + # See https://github.com/python-poetry/poetry/issues/8638 + bin_dir = "Scripts" if bin_path.exists() else "bin" + else: + bin_dir = "bin" activate_path = env.path / bin_dir / activate_script # mypy requires using sys.platform instead of WINDOWS constant