python-poetry/poetry · error · ShellNotSupportedError
Discovered shell '{shell}' doesn't have an activator in virt
Error message
Discovered shell '{shell}' doesn't have an activator in virtual environment What it means
`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.
Source
Thrown at src/poetry/console/commands/env/activate.py:37
class ShellNotSupportedError(Exception):
"""Raised when a shell doesn't have an activator in virtual environment"""
class EnvActivateCommand(EnvCommand):
name = "env activate"
description = "Print the command to activate a virtual environment."
def handle(self) -> int:
try:
shell, _ = shellingham.detect_shell()
except shellingham.ShellDetectionFailure:
shell = ""
if command := self._get_activate_command(self.env, shell):
self.line(command)
return 0
raise ShellNotSupportedError(
f"Discovered shell '{shell}' doesn't have an activator in virtual environment"
)
def _get_activate_command(self, env: Env, shell: str) -> str:
if shell == "fish":
command, filename = "source", "activate.fish"
elif shell == "nu":
command, filename = "overlay use", "activate.nu"
elif shell in ["csh", "tcsh"]:
command, filename = "source", "activate.csh"
elif shell in ["powershell", "pwsh"]:
command, filename = "&", "activate.ps1"
elif shell == "cmd":
command, filename = "", "activate.bat"
elif shell in ["bash", "mksh", "zsh"]:
command, filename = "source", "activate"
else:
command, filename = ".", "activate"View on GitHub (pinned to 92b74dcfe3)
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.
Example fix
# before poetry env activate # ShellNotSupportedError # after SHELL=/bin/bash poetry env activate
Defensive patterns
Strategy: fallback
Validate before calling
import os, shutil
shell = os.environ.get("SHELL", "")
if not shell or shutil.which(shell.split("/")[-1]) is None:
# detection will likely fail; instruct manual activation
print("set SHELL or source <venv>/bin/activate manually") Type guard
def has_activator(venv_bin_dir, shell: str) -> bool:
from pathlib import Path
mapping = {"fish": "activate.fish", "nu": "activate.nu", "csh": "activate.csh",
"tcsh": "activate.csh", "powershell": "activate.ps1",
"pwsh": "activate.ps1", "cmd": "activate.bat",
"bash": "activate", "mksh": "activate", "zsh": "activate"}
fname = mapping.get(shell, "activate")
return (Path(venv_bin_dir) / fname).exists() Try / catch
from poetry.console.commands.env.activate import ShellNotSupportedError
try:
...
except ShellNotSupportedError:
# fall back to manual activation path
print(f"source {venv_bin}/activate") Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- embedded {distribution} wheel not found
- Command {e.cmd} errored with the following return code {e.re
- Could not find the python executable {expected}
- Env {env_name} doesn't belong to this project.
- <warning>Environment "{python}" does not exist.</warning>
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/62254c32b0b4b5c9.json.
Report an issue: GitHub.