poetry run pytest, ignores poetry config settings.virtualenvs.create false

Created on 31 Jul 2019  路  4Comments  路  Source: python-poetry/poetry

  • [ ] 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).

Issue


We installed poetry into docker following these steps:

    - apt-get update -yqq
    - apt-get upgrade -yqq
    - apt-get install -yqq --no-install-recommends build-essential python-dev
    - pip install -U pip poetry
    - poetry config settings.virtualenvs.create false
    - poetry install --no-interaction --no-ansi
    - poetry run pytest

as we only have this package into the docker image, we don't care about virtualenvs, this is the reason we have this: poetry config settings.virtualenvs.create false

when testing into the CI environment, when running the docker container with a non privileged user like: USER nobody

 docker run  --rm <DOCKER_IMAGE> poetry run pytest

if fails, raising this error:

$ docker run  --rm <DOCKER_IMAGE> poetry run pytest
Creating virtualenv upsell-py3.7 in /nonexistent/.cache/pypoetry/virtualenvs

[PermissionError]
[Errno 13] Permission denied: '/nonexistent'

run <args> (<args>)...

So, my conclusion is that even when explicitly set to not create virtualenvs:

poetry config settings.virtualenvs.create false

this setting is ignored when using: poetry run

Bug CLI

Most helpful comment

@jfunez Could you test with the latest 1.0.0b2 release and by setting a POETRY_VIRTUALENVS_CREATE=false environment variables. If you want more information about this new feature you can check #1272

All 4 comments

@jfunez the problem here is that when you execute poetry config settings.virtualenvs.create false, the configuration is written to $HOME/.config/pypoetry/config.toml. The environment variable $HOME on most containers on Docker Hub (eg: python:3.7) will evaluate to /root.

During build, in your case, poetry updates its configuration such that it pertains only to the root user (/root/.config/pypoetry/config.toml). Once you switch user to nobody, $HOME evaluates to /nonexistent. This, as the name suggests, does not exist and hence poetry assumes defaults which is to create virtualenvs.

This leads to your reported issue.

@jfunez Could you test with the latest 1.0.0b2 release and by setting a POETRY_VIRTUALENVS_CREATE=false environment variables. If you want more information about this new feature you can check #1272

hi @sdispater
not now, but I will try asap!
thanks!

Closing this for now. @jfunez If the suggestion I made does not fix the issue, feel free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeremy886 picture jeremy886  路  3Comments

kierun picture kierun  路  3Comments

thmo picture thmo  路  3Comments

etijskens picture etijskens  路  3Comments

probablykasper picture probablykasper  路  3Comments