Skip to content

"Poetry env activate" doesn't get recognized in fish and bash shell unless command "poetry env use <python version> is run before. #10084

@ghost

Description

Description

When using the new "poetry env activate" command, I get the following output:

Image

Expected output after running "poetry env use 3.12" at least once:

Image

The issue I take here is that on Windows PowerShell, the env use command is not necessary. Here, poetry Install is enough.
Maybe it is expected behavior, but it is not consistent across platforms.

Workarounds

Run "poetry env use" beforehand.

Poetry Installation Method

install.python-poetry.org

Operating System

Fedora 41

Poetry Version

Poetry (version 2.0.1)

Poetry Configuration

cache-dir = "/home/vdlugosch-zalf/.cache/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/vdlugosch-zalf/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Paste the output of 'python -m sysconfig', over this line.

Example pyproject.toml

Poetry Runtime Logs

Loading configuration file /home/vdlugosch-zalf/.config/pypoetry/config.toml

Stack trace:

7 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/cleo/application.py:327 in run
325│
326│ try:
→ 327│ exit_code = self._run(io)
328│ except BrokenPipeError:
329│ # If we are piped to another process, it may close early and send a

6 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/poetry/console/application.py:236 in _run
234│
235│ with directory(self._working_directory):
→ 236│ exit_code: int = super()._run(io)
237│
238│ return exit_code

5 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/cleo/application.py:431 in _run
429│ io.input.interactive(interactive)
430│
→ 431│ exit_code = self._run_command(command, io)
432│ self._running_command = None
433│

4 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/cleo/application.py:473 in _run_command
471│
472│ if error is not None:
→ 473│ raise error
474│
475│ return terminate_event.exit_code

3 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/cleo/application.py:457 in _run_command
455│
456│ if command_event.command_should_run():
→ 457│ exit_code = command.run(io)
458│ else:
459│ exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

2 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/cleo/commands/base_command.py:117 in run
115│ io.input.validate()
116│
→ 117│ return self.execute(io) or 0
118│
119│ def merge_application_definition(self, merge_args: bool = True) -> None:

1 ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/cleo/commands/command.py:61 in execute
59│
60│ try:
→ 61│ return self.handle()
62│ except KeyboardInterrupt:
63│ return 1

ShellNotSupportedError

Discovered shell doesn't have an activator in virtual environment

at ~/.local/share/pypoetry/venv/lib64/python3.12/site-packages/poetry/console/commands/env/activate.py:34 in handle
30│ if command := self._get_activate_command(env):
31│ self.line(command)
32│ return 0
33│ else:
→ 34│ raise ShellNotSupportedError(
35│ "Discovered shell doesn't have an activator in virtual environment"
36│ )
37│
38│ def _get_activate_command(self, env: Env) -> str:

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions