Skip to content

Symlinks are not resolved properly to check location. #3842

Closed
@frostming

Description

@frostming

pipenv/pipenv/project.py

Lines 50 to 54 in 2370340

if not loc.is_absolute():
try:
loc = loc.resolve()
except OSError:
loc = loc.absolute()

def dist_is_in_project(self, dist):
"""Determine whether the supplied distribution is in the environment."""
from .project import _normalized
prefixes = [
_normalized(prefix) for prefix in self.base_paths["libdirs"].split(os.pathsep)
if _normalized(prefix).startswith(_normalized(self.prefix.as_posix()))
]
location = self.locate_dist(dist)
if not location:
return False
location = _normalized(make_posix(location))
return any(location.startswith(prefix) for prefix in prefixes)

The path is never resolved if it is an absolute path with symlinked parts. It is often the case with Linux, where the virtualenv home is symlinked to ~/.local/share/, then dist_is_in_project will always return false.

Remove the is_absolute check in _normalize funciton can make it work.

More info FWIW: I have virtualenvwrapper installed and WORKON_HOME set to ~/.virtualenvs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions