Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If .venv is an empty directory, poetry installs dependencies globally #286

Closed
3 tasks done
jacebrowning opened this issue Jul 6, 2018 · 6 comments · Fixed by #1797
Closed
3 tasks done

If .venv is an empty directory, poetry installs dependencies globally #286

jacebrowning opened this issue Jul 6, 2018 · 6 comments · Fixed by #1797
Assignees
Labels
area/venv Related to virtualenv management kind/bug Something isn't working as expected

Comments

@jacebrowning
Copy link
Contributor

  • 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: 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
@jacebrowning
Copy link
Contributor Author

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.

@onlined onlined mentioned this issue Nov 29, 2018
@drunkwcodes
Copy link

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

@strayer
Copy link

strayer commented May 17, 2019

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.

@eff917
Copy link

eff917 commented Nov 19, 2019

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.

@TheButlah
Copy link
Contributor

TheButlah commented Dec 16, 2019

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.

@finswimmer finswimmer added kind/bug Something isn't working as expected area/venv Related to virtualenv management labels Dec 16, 2019
@finswimmer finswimmer self-assigned this Dec 27, 2019
sdispater added a commit that referenced this issue Jan 9, 2020
* change (env.py): force recreation of venv if it is not sane

* new (env): add warning when forcing recreation

* fix (env): warning about broken venv placed right before calling recreation

* Update poetry/utils/env.py

Co-Authored-By: Sébastien Eustace <[email protected]>

Co-authored-by: Sébastien Eustace <[email protected]>
dimbleby added a commit to dimbleby/poetry that referenced this issue Apr 21, 2022
* Marker name is a string, not a lexer token

* add unit test
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/venv Related to virtualenv management kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants