Poetry: If .venv is an empty directory, poetry installs dependencies globally

Created on 6 Jul 2018  ·  5Comments  ·  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: macOS 10.13.5
  • Poetry version: 0.11.2
  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

  1. Check out any poetry project
  2. $ rm -rf .venv && mkdir .venv
  3. ⚠️ $ poetry install ⚠️
  4. Your dependencies are now installed globally
Bug Virtualenvs

Most helpful comment

This is still an issue in 1.0.0b5

Another use case is creating it with a placeholder file in code repository, that way poetry automatically uses it without having to explicitly set poetry settings.

All 5 comments

At a minimum, we need an assertion to prevent this, but it would be nice if Poetry could turn an empty directory into a virtual environment.

And perhaps "empty" should mean that "bin/python" is absent.

Does it mean it has to be if env.is_venv() and env.is_sane() in https://github.com/sdispater/poetry/blob/master/poetry/utils/env.py#L209

To add a realistic situation where this can happen: We do our development in Docker containers and mount a volume in the container at /app/.venv – meaning an empty .venv directory just as described will exist and break poetry.

For now, we just mount the volume at $HOME/.cache/pypoetry/virtualenvs and let poetry handle virtualenvs there to avoid this issue, but we'd prefer to keep using settings.virtualenvs.in-project.

This is still an issue in 1.0.0b5

Another use case is creating it with a placeholder file in code repository, that way poetry automatically uses it without having to explicitly set poetry settings.

I'm also running into this issue with poetry 1.0.0 (stable). in my case, .venv is a docker volume so it has already been mounted and therefore the folder is empty. This means that poetry installs its dependencies globally instead of in the volume. This is annoying because whenever the docker container gets destroyed, i have to reinstall all the dependencies since I cant install them in the volume.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kierun picture kierun  ·  3Comments

probablykasper picture probablykasper  ·  3Comments

nikaro picture nikaro  ·  3Comments

Euphorbium picture Euphorbium  ·  3Comments

ghost picture ghost  ·  3Comments