Skip to content

fix: "already activated" message but shell is not active - #57

Open
kenttonino wants to merge 6 commits into
python-poetry:mainfrom
kenttonino:fix/should-return-false-if-poetry-active-but-not-virtual-env
Open

kenttonino wants to merge 6 commits into
python-poetry:mainfrom
kenttonino:fix/should-return-false-if-poetry-active-but-not-virtual-env

Conversation

@kenttonino

@kenttonino kenttonino commented Apr 9, 2026 •

Copy link
Copy Markdown

Summary

  • Fixes Poetry shell command does not start shell #21
  • If we have a newly created shell, then deactivate, then activate the shell again, it will only show a message that Virtual environment already activated, but its not activated.
    • The problem is that we only check if the POETRY_ACTIVE is set, but not the VIRTUAL_ENV.


Changes

  • command.py:
    • If the POETRY_ACTIVE is set but not the VIRTUAL_ENV, pop the POETRY_ACTIVE.


Test Plan

Test 1

  • Create shell.
  • Deactivate the shell.
  • Activate again the shell.
    • It should activate the shell.

Test 2

  • Activate the shell.
  • Then, activate again.
    • It should show Virtual environment already activated.

@kenttonino kenttonino changed the title [ fix ] Should Return False if POETRY_ACTIVE is true but not VIRTUAL_ENV [ fix ] Already Activated But Shell Is Not Active Apr 9, 2026
@kenttonino kenttonino changed the title [ fix ] Already Activated But Shell Is Not Active [ fix ] Already Activated But Shell Is Not Active (in progress) Apr 9, 2026
@kenttonino
kenttonino marked this pull request as ready for review April 9, 2026 17:09
@kenttonino kenttonino changed the title [ fix ] Already Activated But Shell Is Not Active (in progress) [ fix ] Already Activated But Shell Is Not Active Apr 9, 2026
@kenttonino kenttonino changed the title [ fix ] Already Activated But Shell Is Not Active [ fix ] Already Activated Message But Shell Is Not Active Apr 9, 2026
@kenttonino kenttonino changed the title [ fix ] Already Activated Message But Shell Is Not Active fix: "already activated" message but shell is not active Apr 10, 2026
@kenttonino

Copy link
Copy Markdown
Author

Thanks for the feedback @StantonMatt. Will add additional test case.

@kenttonino

Copy link
Copy Markdown
Author

Hello @StantonMatt. Done adding the test case for stale POETRY_ACTIVE without VIRTUAL_ENV path. Kindly check if available. Thanks.

Also tested on my machine:

ProductName:		macOS
ProductVersion:		26.5.1
BuildVersion:		25F80
image

@yangfan-yf-yf yangfan-yf-yf left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the current head 96ebc6b independently. The new regression test now directly covers the stale state: with POETRY_ACTIVE=1 and no VIRTUAL_ENV, the command invokes Shell.activate() instead of reporting an already-active environment. The existing active-environment test explicitly provides VIRTUAL_ENV and retains the early-return behavior.

Local verification on Windows with Python 3.12:

  • python -m pytest -q — 18 passed
  • git diff --check

The GitHub Ubuntu, macOS, and Windows matrix is also green on the current head. The local Ruff and MyPy commands still report findings in unchanged shell.py and tests/conftest.py, respectively; they are outside this PR's diff.

@kenttonino

kenttonino commented Jul 27, 2026 •

Copy link
Copy Markdown
Author

Thanks @yangfan-yf-yf. Will take a look on this one. However, the fix will be on a separate PR.

I reviewed the current head 96ebc6b independently. The new regression test now directly covers the stale state: with POETRY_ACTIVE=1 and no VIRTUAL_ENV, the command invokes Shell.activate() instead of reporting an already-active environment. The existing active-environment test explicitly provides VIRTUAL_ENV and retains the early-return behavior.

Local verification on Windows with Python 3.12:

  • python -m pytest -q — 18 passed
  • git diff --check

The GitHub Ubuntu, macOS, and Windows matrix is also green on the current head. The local Ruff and MyPy commands still report findings in unchanged shell.py and tests/conftest.py, respectively; they are outside this PR's diff.

@PNHD PNHD mentioned this pull request Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poetry shell command does not start shell

2 participants