fix poetry env activate for Bash on Windows
#10415
+146
−22
Closed
Cirrus CI / Tests / FreeBSD (Python 3.11) / pytest
failed
Jun 2, 2025 in 3m 58s
Task Summary
Instruction pytest failed in 01:51
Details
✅ 00:03 clone
✅ 01:17 bootstrap_poetry
✅ 00:41 setup_environment
❌ 01:51 pytest
expected_prefix: str,
) -> None:
mocker.patch("shellingham.detect_shell", return_value=(shell, None))
mocker.patch("poetry.utils.env.EnvManager.get", return_value=tmp_venv)
> tester.execute()
/tmp/cirrus-ci-build/tests/console/commands/env/test_activate.py:99:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
return self.handle()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <poetry.console.commands.env.activate.EnvActivateCommand object at 0x1cd10201cc10>
def handle(self) -> int:
from poetry.utils.env import EnvManager
env = EnvManager(self.poetry).get()
try:
shell, *_ = shellingham.detect_shell()
except shellingham.ShellDetectionFailure:
shell = ""
if command := self._get_activate_command(env, shell):
self.line(command)
return 0
> raise ShellNotSupportedError(
f"Discovered shell '{shell}' doesn't have an activator in virtual environment"
)
E poetry.console.commands.env.activate.ShellNotSupportedError: Discovered shell 'cmd' doesn't have an activator in virtual environment
/tmp/cirrus-ci-build/src/poetry/console/commands/env/activate.py:39: ShellNotSupportedError
------------------------------ Captured log setup ------------------------------
INFO virtualenv.discovery.builtin:builtin.py:76 find interpreter for spec PythonSpec(path=/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/bin/python)
INFO virtualenv.discovery.builtin:builtin.py:83 proposed PythonInfo(spec=CPython3.11.11.final.0-64, system=/usr/local/bin/python3.11, exe=/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/bin/python, platform=freebsd14, version='3.11.11 (main, Apr 12 2025, 01:11:42) [Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2', encoding_fs_io=utf-8-utf-8)
INFO virtualenv.run.session:session.py:52 create virtual environment via CPython3Posix(dest=/tmp/pytest-of-root/pytest-0/popen-gw0/test_env_activate_windows_shel0/venv, clear=False, no_vcs_ignore=False, global=False)
INFO virtualenv.run.session:session.py:65 add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
-------------- generated xml file: /tmp/cirrus-ci-build/junit.xml --------------
=========================== short test summary info ============================
SKIPPED [1] tests/installation/test_executor.py:414: https://github.com/python-poetry/poetry/issues/7983
SKIPPED [1] tests/utils/test_python_manager.py:99: Windows only
SKIPPED [1] tests/console/commands/test_run.py:159: Poetry only installs CMD script files for console scripts of editable dependencies on Windows
SKIPPED [1] tests/integration/test_utils_vcs_git.py:320: HTTP authentication credentials not available
SKIPPED [1] tests/console/commands/test_sync.py:26: Only relevant for `poetry install`
SKIPPED [1] tests/utils/env/test_env_manager.py:1265: requires darwin
SKIPPED [3] tests/console/commands/env/test_activate.py:53: Only Windows shells
SKIPPED [1] tests/console/commands/self/test_sync.py:26: Only relevant for `poetry self install`
FAILED tests/console/commands/env/test_activate.py::test_env_activate_windows_shells_get_quoted_path_only[cmd-activate.bat-] - poetry.console.commands.env.activate.ShellNotSupportedError: Discovered shell 'cmd' doesn't have an activator in virtual environment
============ 1 failed, 2672 passed, 10 skipped in 108.95s (0:01:48) ============Annotations
Check failure on line 99 in tests/console/commands/env/test_activate.py
cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest
tests/console/commands/env/test_activate.py#L99
tests.console.commands.env.test_activate.test_env_activate_windows_shells_get_quoted_path_only[cmd-activate.bat-]
Raw output
tmp_venv = VirtualEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_env_activate_windows_shel0/venv")
mocker = <pytest_mock.plugin.MockerFixture object at 0x1cd10319afd0>
tester = <cleo.testers.command_tester.CommandTester object at 0x1cd10201cc90>
shell = 'cmd', ext = 'activate.bat', expected_prefix = ''
@pytest.mark.parametrize(
"shell, ext, expected_prefix",
(
("cmd", "activate.bat", ""),
("pwsh", "activate.ps1", "& "),
("powershell", "activate.ps1", "& "),
),
)
def test_env_activate_windows_shells_get_quoted_path_only(
tmp_venv: VirtualEnv,
mocker: MockerFixture,
tester: CommandTester,
shell: str,
ext: str,
expected_prefix: str,
) -> None:
mocker.patch("shellingham.detect_shell", return_value=(shell, None))
mocker.patch("poetry.utils.env.EnvManager.get", return_value=tmp_venv)
> tester.execute()
/tmp/cirrus-ci-build/tests/console/commands/env/test_activate.py:99:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
return self.handle()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <poetry.console.commands.env.activate.EnvActivateCommand object at 0x1cd10201cc10>
def handle(self) -> int:
from poetry.utils.env import EnvManager
env = EnvManager(self.poetry).get()
try:
shell, *_ = shellingham.detect_shell()
except shellingham.ShellDetectionFailure:
shell = ""
if command := self._get_activate_command(env, shell):
self.line(command)
return 0
> raise ShellNotSupportedError(
f"Discovered shell '{shell}' doesn't have an activator in virtual environment"
)
E poetry.console.commands.env.activate.ShellNotSupportedError: Discovered shell 'cmd' doesn't have an activator in virtual environment
/tmp/cirrus-ci-build/src/poetry/console/commands/env/activate.py:39: ShellNotSupportedError
Loading