Skip to content

Virtualenv not always found in case insensitive filesystem #2419

@absassi

Description

@absassi
  • 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: Windows 10

  • Poetry version: 1.0.5

  • Link of a Gist with the contents of your pyproject.toml file: irrelevant

Issue

Poetry does not consider case sensitivity of the filesystem when computing the hash of the virtual environment name. This makes it to fail to find the environment in case insensitive filesystems depending on the case of letters in the path.

For example, in Windows, having a project named "test" in C:\test and accessing it from c:\test or C:\Test or any other case variation. This cannot be done from command prompt, as it always canonicalize the path, but it can be easily done from scripts (e.g. Jenkinsfile).

The hash is computed in EnvManager.generate_env_name in poetry.utils.env:

>>> from poetry.utils.env import EnvManager
>>> EnvManager.generate_env_name('test', 'C:\\test')
'test-bFaF-DbV'
>>> EnvManager.generate_env_name('test', 'c:\\test')
'test-7_Oi5G5Y'

I expected the hash to be computed always the same, when the filesystem is case-insensitive (or at least use os.path.normcase or similar, which is does the job in Windows).

Since I cannot control how the path case is in my build environment, the workaround I'm currently using is to set virtualenvs.in-project = true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions