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

Collisions of virtual environments #3151

Closed
Jamim opened this issue Nov 2, 2018 · 1 comment · Fixed by #2883
Closed

Collisions of virtual environments #3151

Jamim opened this issue Nov 2, 2018 · 1 comment · Fixed by #2883
Labels
OS: Linux This issue affects the Linux Operating System. Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior.

Comments

@Jamim
Copy link
Contributor

Jamim commented Nov 2, 2018

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 --venv

Here 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-Ic8GqeXz

As 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.7m
  • 3.7.0: /usr/bin/python3.7
  • 3.6.6: /usr/bin/python3.6
  • 3.6.6: /usr/bin/python3.6m
  • 2.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_MODULE
  • LS_COLORS
  • LC_MEASUREMENT
  • LESSCLOSE
  • LC_PAPER
  • LC_MONETARY
  • XDG_MENU_PREFIX
  • LANG
  • DISPLAY
  • GNOME_SHELL_SESSION_MODE
  • COLORTERM
  • USERNAME
  • XDG_VTNR
  • SSH_AUTH_SOCK
  • MANDATORY_PATH
  • LC_NAME
  • XDG_SESSION_ID
  • USER
  • DESKTOP_SESSION
  • QT4_IM_MODULE
  • TEXTDOMAINDIR
  • GNOME_TERMINAL_SCREEN
  • DEFAULTS_PATH
  • PWD
  • HOME
  • TEXTDOMAIN
  • SSH_AGENT_PID
  • QT_ACCESSIBILITY
  • XDG_SESSION_TYPE
  • XDG_DATA_DIRS
  • XDG_SESSION_DESKTOP
  • LC_ADDRESS
  • GJS_DEBUG_OUTPUT
  • LC_NUMERIC
  • GTK_MODULES
  • PAPERSIZE
  • WINDOWPATH
  • VTE_VERSION
  • TERM
  • SHELL
  • QT_IM_MODULE
  • XMODIFIERS
  • IM_CONFIG_PHASE
  • XDG_CURRENT_DESKTOP
  • GPG_AGENT_INFO
  • GNOME_TERMINAL_SERVICE
  • XDG_SEAT
  • SHLVL
  • LC_TELEPHONE
  • GDMSESSION
  • GNOME_DESKTOP_SESSION_ID
  • LOGNAME
  • DBUS_SESSION_BUS_ADDRESS
  • XDG_RUNTIME_DIR
  • XAUTHORITY
  • XDG_CONFIG_DIRS
  • PATH
  • LC_IDENTIFICATION
  • GJS_DEBUG_TOPICS
  • SESSION_MANAGER
  • LESSOPEN
  • GTK_IM_MODULE
  • LC_TIME
  • _
  • OLDPWD
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PIP_SHIMS_BASE_MODULE
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_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/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /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.

@techalchemy
Copy link
Member

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!

@techalchemy techalchemy added Type: Bug 🐛 This issue is a bug. OS: Linux This issue affects the Linux Operating System. Type: Regression This issue is a regression of a previous behavior. labels Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Linux This issue affects the Linux Operating System. Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants