{"id":"62254c32b0b4b5c9","repo":"python-poetry/poetry","slug":"discovered-shell-shell-doesn-t-have-an-activat","errorCode":null,"errorMessage":"Discovered shell '{shell}' doesn't have an activator in virtual environment","messagePattern":"Discovered shell '(.+?)' doesn't have an activator in virtual environment","errorType":"exception","errorClass":"ShellNotSupportedError","httpStatus":null,"severity":"error","filePath":"src/poetry/console/commands/env/activate.py","lineNumber":37,"sourceCode":"class ShellNotSupportedError(Exception):\n    \"\"\"Raised when a shell doesn't have an activator in virtual environment\"\"\"\n\n\nclass EnvActivateCommand(EnvCommand):\n    name = \"env activate\"\n    description = \"Print the command to activate a virtual environment.\"\n\n    def handle(self) -> int:\n        try:\n            shell, _ = shellingham.detect_shell()\n        except shellingham.ShellDetectionFailure:\n            shell = \"\"\n\n        if command := self._get_activate_command(self.env, shell):\n            self.line(command)\n            return 0\n\n        raise ShellNotSupportedError(\n            f\"Discovered shell '{shell}' doesn't have an activator in virtual environment\"\n        )\n\n    def _get_activate_command(self, env: Env, shell: str) -> str:\n        if shell == \"fish\":\n            command, filename = \"source\", \"activate.fish\"\n        elif shell == \"nu\":\n            command, filename = \"overlay use\", \"activate.nu\"\n        elif shell in [\"csh\", \"tcsh\"]:\n            command, filename = \"source\", \"activate.csh\"\n        elif shell in [\"powershell\", \"pwsh\"]:\n            command, filename = \"&\", \"activate.ps1\"\n        elif shell == \"cmd\":\n            command, filename = \"\", \"activate.bat\"\n        elif shell in [\"bash\", \"mksh\", \"zsh\"]:\n            command, filename = \"source\", \"activate\"\n        else:\n            command, filename = \".\", \"activate\"","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/console/commands/env/activate.py#L19-L55","documentation":"`ShellNotSupportedError` raised by `poetry env activate` (activate.py:33-39) when `shellingham.detect_shell()` either fails (shell becomes `''`) or returns a shell for which the corresponding activation script does not exist in `env.bin_dir`. The supported scripts are activate.fish/.nu/.csh/.ps1/.bat/activate.","triggerScenarios":"Running `poetry env activate` inside a venv that was created without activation scripts (e.g. `--without-pip` or a broken venv); running under a shell shellingham cannot detect (some login managers, containers); the detected shell's script file is missing.","commonSituations":"CI containers with no real shell; minimal venvs; shells like `xonsh` or `elvish` whose activator was never generated; venv built with `--without-pip` which can skip some scripts.","solutions":["Recreate the venv normally: `poetry env remove python && poetry install`.","Set the shell explicitly via the `SHELL` env var (e.g. `SHELL=/bin/bash poetry env activate`) so shellingham detects it.","Manually source the activator: `<venv>/bin/activate` for bash/zsh."],"exampleFix":"# before\npoetry env activate   # ShellNotSupportedError\n# after\nSHELL=/bin/bash poetry env activate","handlingStrategy":"fallback","validationCode":"import os, shutil\nshell = os.environ.get(\"SHELL\", \"\")\nif not shell or shutil.which(shell.split(\"/\")[-1]) is None:\n    # detection will likely fail; instruct manual activation\n    print(\"set SHELL or source <venv>/bin/activate manually\")","typeGuard":"def has_activator(venv_bin_dir, shell: str) -> bool:\n    from pathlib import Path\n    mapping = {\"fish\": \"activate.fish\", \"nu\": \"activate.nu\", \"csh\": \"activate.csh\",\n               \"tcsh\": \"activate.csh\", \"powershell\": \"activate.ps1\",\n               \"pwsh\": \"activate.ps1\", \"cmd\": \"activate.bat\",\n               \"bash\": \"activate\", \"mksh\": \"activate\", \"zsh\": \"activate\"}\n    fname = mapping.get(shell, \"activate\")\n    return (Path(venv_bin_dir) / fname).exists()","tryCatchPattern":"from poetry.console.commands.env.activate import ShellNotSupportedError\ntry:\n    ...\nexcept ShellNotSupportedError:\n    # fall back to manual activation path\n    print(f\"source {venv_bin}/activate\")","preventionTips":["Create venvs with full activation scripts (avoid `--without-pip`).","Set `SHELL` explicitly in CI containers.","Keep a manual `source <venv>/bin/activate` documented as fallback."],"tags":["virtualenv","shell","activation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}