question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I ignore the 'VIRTUAL_ENV' environment variable?

See original GitHub issue
  • 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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bertjwregeercommented, Jul 6, 2018

@jacebrowning, run poetry while unsetting VIRTUAL_ENV:

env -u VIRTUAL_ENV poetry

Now even though you are “Inside” an virtual environment, poetry won’t know about it.

0reactions
stale[bot]commented, Nov 20, 2019

Closing this issue automatically because it has not had any activity since it has been marked as stale. If you think it is still relevant and should be addressed, feel free to open a new one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gitignore syntax - how to exclude virtualenv sub-directories?
gitignore folder just add the name of the folder with a slash at the end. This will ignore all sub directories in the...
Read more >
How to use Python Virtualenv and Environment variables on ...
How to use Python Virtualenv and Environment variables on windows. TutorialSupport the channelPaypal.
Read more >
Disable pip Outside of Virtual Environments
If you want to actually install something outside of a virtual environment, you can temporarily clear that env variable: env PIP_REQUIRE_ ...
Read more >
Should I add .env to .gitignore?
The short answer is, “yes”. You should use your .gitignore file to ignore the .env file. Why Ignore .env. The .env file is...
Read more >
venv — Creation of virtual environments
You can deactivate a virtual environment by typing deactivate in your shell. The exact mechanism is platform-specific and is an internal implementation detail...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found