Repository navigation
Collisions of virtual environments #3151
Description
Issue description
On OS which handles file systems in case-sensitive manner (e.g. Linux based), pipenv mistakenly uses virtual environment which corresponds to similar-named directory if it exists.
Expected result
pipenv creates and uses different virtual environments for projects in different directories which names are equals when they are normalized to lower or upper case.
Actual result
pipenv uses single virtual environment for different projects.
Steps to replicate
mkdir pipenv-tests/{test,TEST} -p
cd pipenv-tests/test
pipenv shell
pipenv --venv
exit
cd ../TEST
pipenv shell
pipenv --venvHere is what I've got using d985784 revision of pipenv (current master):
~/projects $ mkdir pipenv-tests/{test,TEST} -p
~/projects $ cd pipenv-tests/test
~/projects/pipenv-tests/test $ pipenv shell
Creating a virtualenv for this project…
Pipfile: /home/mim/projects/pipenv-tests/test/Pipfile
Using /usr/bin/python3 (3.6.6) to create virtualenv…
✔ Complete Running... Installing setuptools, pip, wheel...done.
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/mim/.local/share/virtualenvs/test-Ic8GqeXz/bin/python3
Also creating executable in /home/mim/.local/share/virtualenvs/test-Ic8GqeXz/bin/python
Installing setuptools, pip, wheel...done.
Virtualenv location: /home/mim/.local/share/virtualenvs/test-Ic8GqeXz
Creating a Pipfile for this project…
Launching subshell in virtual environment…
~/projects/pipenv-tests/test $ . /home/mim/.local/share/virtualenvs/test-Ic8GqeXz/bin/activate
(test) ~/projects/pipenv-tests/test $ pipenv --venv
/home/mim/.local/share/virtualenvs/test-Ic8GqeXz
(test) ~/projects/pipenv-tests/test $ exit
exit
~/projects/pipenv-tests/test $ cd ../TEST
~/projects/pipenv-tests/TEST $ pipenv shell
Creating a Pipfile for this project…
Launching subshell in virtual environment…
~/projects/pipenv-tests/TEST $ . /home/mim/.local/share/virtualenvs/test-Ic8GqeXz/bin/activate
(test) ~/projects/pipenv-tests/TEST $ pipenv --venv
/home/mim/.local/share/virtualenvs/test-Ic8GqeXzAs you can see, /home/mim/.local/share/virtualenvs/test-Ic8GqeXz was used for both test and TEST projects.
Environment
$ lsb_release -d
Description: Ubuntu 18.04.1 LTS$ pipenv --support
Pipenv version: '2018.10.14.dev0'
Pipenv location: '/home/mim/.local/lib/python3.6/site-packages/pipenv'
Python location: '/usr/bin/python3'
Python installations found:
3.7.0:/usr/bin/python3.7m3.7.0:/usr/bin/python3.73.6.6:/usr/bin/python3.63.6.6:/usr/bin/python3.6m2.7.15rc1:/usr/bin/python2
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.6.6',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '4.15.0-38-generic',
'platform_system': 'Linux',
'platform_version': '#41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018',
'python_full_version': '3.6.6',
'python_version': '3.6',
'sys_platform': 'linux'}
System environment variables:
CLUTTER_IM_MODULELS_COLORSLC_MEASUREMENTLESSCLOSELC_PAPERLC_MONETARYXDG_MENU_PREFIXLANGDISPLAYGNOME_SHELL_SESSION_MODECOLORTERMUSERNAMEXDG_VTNRSSH_AUTH_SOCKMANDATORY_PATHLC_NAMEXDG_SESSION_IDUSERDESKTOP_SESSIONQT4_IM_MODULETEXTDOMAINDIRGNOME_TERMINAL_SCREENDEFAULTS_PATHPWDHOMETEXTDOMAINSSH_AGENT_PIDQT_ACCESSIBILITYXDG_SESSION_TYPEXDG_DATA_DIRSXDG_SESSION_DESKTOPLC_ADDRESSGJS_DEBUG_OUTPUTLC_NUMERICGTK_MODULESPAPERSIZEWINDOWPATHVTE_VERSIONTERMSHELLQT_IM_MODULEXMODIFIERSIM_CONFIG_PHASEXDG_CURRENT_DESKTOPGPG_AGENT_INFOGNOME_TERMINAL_SERVICEXDG_SEATSHLVLLC_TELEPHONEGDMSESSIONGNOME_DESKTOP_SESSION_IDLOGNAMEDBUS_SESSION_BUS_ADDRESSXDG_RUNTIME_DIRXAUTHORITYXDG_CONFIG_DIRSPATHLC_IDENTIFICATIONGJS_DEBUG_TOPICSSESSION_MANAGERLESSOPENGTK_IM_MODULELC_TIME_OLDPWDPIP_DISABLE_PIP_VERSION_CHECKPIP_SHIMS_BASE_MODULEPYTHONDONTWRITEBYTECODEPIP_PYTHON_PATHPYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH:/home/mim/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binSHELL:/bin/bashLANG:en_US.UTF-8PWD:/home/mim/projects
Root cause
I tried to investigate this bug and found that it was introduced by #2513.
The root cause of the issue is that os.name != "nt" condition was mistakenly converted to fnmatch.fnmatch('A', 'a') when it should have been converted to not fnmatch.fnmatch('A', 'a').
Solution
I created a PR #2883 that fixes this issue.
Activity
techalchemy commentedon Nov 3, 2018
OH
this is awesome, and makes perfect sense now
also it's quite bad that it happens in the first place, thank you for your patience and for the fix!