Skip to content

(🐞) env use system outputs an incorrect/confusing message "Deactivating virtualenv" #7147

Open

Description

@KotlinIsland
  • Poetry version: 1.2.2
  • Python version: 3.11.0
  • OS version and name: Windows 21H2
  • pyproject.toml: nah
  • [πŸš€] I am on the latest stable Poetry version, installed using a recommended method.
  • [πŸš€] I have searched the issues of this repo and believe that this is not a duplicate.
  • [πŸš€] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [πŸš€] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

poetry env use system(when a venv is active) has a confusing message in the output that looks incorrect.

πŸ‘‰ poetry env info

Virtualenv
Python:         3.10.8
Implementation: CPython                  
Path:           C:\Users\AMONGUS\projects\test\.venv
Executable:     C:\Users\AMONGUS\projects\test\.venv\Scripts\python.exe
Valid:          True

System
Platform:   win32
OS:         nt
Python:     3.10.8
Path:       C:\Users\AMONGUS\AppData\Local\Programs\Python\Python310
Executable: C:\Users\AMONGUS\AppData\Local\Programs\Python\Python310\python.exe
πŸ‘‰ poetry env use system
Deactivating virtualenv: C:\Users\AMONGUS\AppData\Local\pypoetry\Cache\virtualenvs\test-aYKTyqIq-py3.11
πŸ‘‰ $Env:VIRTUAL_ENV; py -0p
C:\Users\AMONGUS\AppData\Local\pypoetry\Cache\virtualenvs\test-aYKTyqIq-py3.11
  *               C:\Users\AMONGUS\AppData\Local\pypoetry\Cache\virtualenvs\test-aYKTyqIq-py3.11\Scripts\python.exe
 -V:3.11          C:\Users\AMONGUS\AppData\Local\Programs\Python\Python311\python.exe
 -V:3.10          C:\Users\AMONGUS\AppData\Local\Programs\Python\Python310\python.exe
πŸ‘‰ poetry env info

Virtualenv
Python:         3.11.0
Implementation: CPython
Path:           C:\Users\AMONGUS\AppData\Local\pypoetry\Cache\virtualenvs\test-aYKTyqIq-py3.11
Executable:     C:\Users\AMONGUS\AppData\Local\pypoetry\Cache\virtualenvs\test-aYKTyqIq-py3.11\Scripts\python.exe
Valid:          True

System
Platform:   win32
OS:         nt
Python:     3.11.0
Path:       C:\Users\AMONGUS\AppData\Local\Programs\Python\Python311
Executable: C:\Users\AMONGUS\AppData\Local\Programs\Python\Python311\python.exe

❓ HUUUUH ❓

Why did it output 'deactivating virtualenv', the active virtualvenv (poetry 3.11) is still active, and poetry env is now set to 3.11?

πŸ‘‰ poetry env use system
Deactivating virtualenv: C:\Users\AMONGUS\AppData\Local\pypoetry\Cache\virtualenvs\test-aYKTyqIq-py3.11

Is this supposed to mean something? or is this a defect and it shouldn't be showing?

TODO:

  • raise another issue regarding the undefined behaviour when you do poetry env use <path to venv>.

Activity

  1. neersighted commented on Dec 6, 2022

    @neersighted
    Member

    What poetry env use does is undefined here; poetry env use system without an existing env and poetry env use <path to venv> are undefined; this command is only meant to be with a 'real' Python. I believe we currently dereference virtual environments, and in general the behavior here is not validated or tested.

    We probably should either rename the command to be poetry env create or figure out semantics for using it with virtual environments.

    The correct way to use an external virtual environment with Poetry is to activate it or manually set VIRTUAL_ENV=/path/to/venv, and then use Poetry as normal.

  2. added
    area/venvRelated to virtualenv management
    kind/questionUser questions (candidates for conversion to discussion)
    and removed
    kind/bugSomething isn't working as expected
    status/triageThis issue needs to be triaged
    on Dec 6, 2022
  3. changed the title [-](🐞) `env use` says `Deactivating virtualenv` when it's actually not deactivating it[/-] [+](🐞) `env use system` has undefied/unexpected behavior when a venv is active[/+] on Dec 6, 2022
  4. KotlinIsland commented on Dec 6, 2022

    @KotlinIsland
    ContributorAuthor

    @neersighted Ohhhhhh, that explains a lot...

    I would expect that env use system would always use the system version of python and never an active venv, WDYT?, comment below.

  5. dimbleby commented on Dec 6, 2022

    @dimbleby
    Contributor

    I would expect that env use system would always use the system version of python

    Could the documentation be clearer? Here's what the help text says

    Usage:
    env use [options] [--] <python>

    Arguments:
    python The python executable to use.

    I don't myself see how that would encourage poetry env use system, but if you want to propose a merge request to make things clearer I expect that would be welcome

  6. KotlinIsland commented on Dec 6, 2022

    @KotlinIsland
    ContributorAuthor

    @dimbleby env use system is from the docs: https://python-poetry.org/docs/managing-environments/#switching-between-environments

    If you want to disable the explicitly activated virtual environment, you can use the special system Python version to retrieve the default behavior

    Hmm, and upon reading that again, makes me think that it's supposed to do what I thought, I'll have to take another look at this...

  7. changed the title [-](🐞) `env use system` has undefied/unexpected behavior when a venv is active[/-] [+](🐞) `env use system` outputs an incorrect/confusing message "Deactivating virtualenv"[/+] on Dec 8, 2022
  8. KotlinIsland commented on Dec 8, 2022

    @KotlinIsland
    ContributorAuthor

    @neersighted Can you take another look at this please, I've changed the OP to focus on the part that looks incorrect.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/venvRelated to virtualenv managementkind/questionUser questions (candidates for conversion to discussion)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions