Skip to content

Commit

Permalink
fix error message when env is not a virtual environment
Browse files Browse the repository at this point in the history
  • Loading branch information
taconi committed Jan 14, 2025
1 parent 852f002 commit 7ce6c82
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/poetry_plugin_shell/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import cast

from poetry.console.commands.env_command import EnvCommand
from poetry.console.exceptions import PoetryConsoleError


if TYPE_CHECKING:
Expand Down Expand Up @@ -42,8 +41,12 @@ def handle(self) -> int:
# Be sure that we have the right type of environment.
env = self.env
if not env.is_venv():
error_msg = "Virtual environment cannot be activated"
raise PoetryConsoleError(error_msg)
self.line("")
self.line_error(
f"The Python environment at <info>{env.path}</> "
"cannot be activated as it is not a virtural environment."
)
return 1
env = cast("VirtualEnv", env)

# Setting this to avoid spawning unnecessary nested shells
Expand Down

0 comments on commit 7ce6c82

Please sign in to comment.