Skip to content

How can I ignore the 'VIRTUAL_ENV' environment variable? #281

@jacebrowning

Description

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

Issue

In my projects, I create the virtual environment in the project root ($ poetry config settings.virtualenvs.in-project true) so that I can explicitly manage dependencies and cache them between builds.

Travis CI runs builds inside of its own virtual environment (thus sets VIRTUAL_ENV).

The current logic consults VIRTUAL_ENV before any other settings: https://github.com/sdispater/poetry/blob/ae1773d68f341c34d9124353f7a952d5fd3cfefb/poetry/utils/venv.py#L47-L50

How can I tell poetry to ignore VIRTUAL_ENV and always create a virtual environment?

pipenv gets around this by adding another environment variable (PIPENV_IGNORE_VIRTUALENVS). but I think poetry can do better.


Proposal A

The default value of settings.virtualenvs.create is inferred from VIRTUAL_ENV (false if set, true if unset).

If the user runs $ poetry config settings.virtualenvs.create true then poetry will always create a virtual environment irrespective of VIRTUAL_ENV.

Proposal B

Add settings.virtualenvs.ignore-active to ignore VIRTUAL_ENV when creating a virtual environment.

Proposal C

If settings.virtualenvs.in-project is set and ./.venv/ does not exist then VIRTUAL_ENV is ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/venvRelated to virtualenv managementkind/featureFeature requests/implementations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions