Skip to content

Allow --force activate poetry shell when poetry fails to activate it #14

@aalok-sathe

Description

@aalok-sathe
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Ubuntu 20.04

  • Poetry version: 1.1.13

Issue

Often times poetry keeps thinking I have a shell already activated, and I don't. This is widely reported by others too (#4622, #21, python-poetry/poetry#5050, python-poetry/poetry#3136). I also do not have any conda environment activated (not even base). In this case, I am just forced to use the full path to the venv to run the activate script manually. I propose that we should be able to do this in poetry, when it inevitable fails to activate the venv, to --force activate the environment, so that even if it is "already active" (not actually), it will still be "activated" (for the first time).

Current output

$ poetry shell -vvv
Using virtualenv: ...-py3.8
Virtual environment already activated: ...-py3.8

Proposed Usage example:

$ poetry shell
Virtual environment already activated: ...

$ poetry shell -f
Force-activating Virtual environment: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions