Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/poetry_plugin_shell/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ def handle(self) -> int:
f"Virtual environment already activated: <info>{self.env.path}</>"
)

# Only activate if not already inside a Poetry-spawned shell (avoid nesting).
if os.environ.get("POETRY_ACTIVE") == "1":
env = self.env
assert env.is_venv()
env = cast("VirtualEnv", env)
shell = Shell.get()
shell.activate(env)

return 0

self.line(f"Spawning shell within <info>{self.env.path}</>")
Expand Down
Loading