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

pipenv run in the same directory from cmd.exe and bash (git for windows) use different virtualenvs #2857

Closed
jerryasher opened this issue Sep 16, 2018 · 9 comments
Assignees
Labels
OS: Windows This issue affects the Windows Operating System. Type: Enhancement 💡 This is a feature or enhancement request.

Comments

@jerryasher
Copy link

Issue description

On a Windows 10 machine, I have

Using cmd.exe I then

  1. cd into a directory that has a Pipfile but no virtualenv created for it
  2. pipenv shell

And I watch as a virtualenv is created in ~.virtualenvs with the modules specified in the Pipfile.

screenshot of my doing the above in a cmd.exe shell

Then using bash.exe from git for windows, I

  • cd into the same directory from above
  • pipenv shell

And I watch as a new and different virtualenv is created in ~.virtualenvs

screenshot of my doing the above in a bash shell

Expected result

I would have expected pipenv run within bash of git for windows to use the virtualenv created by pipenv run within cmd.exe. (Note, powershell, and vscode all use the virtualenv created in the cmd.exe shell)

Actual result

Two different virtualenvs are created

Steps to replicate

Follow the steps above


Please run $ pipenv --support, and paste the results here. Don't put backticks (`) around it! The output already contains Markdown formatting.

C:\Users\jerry\d\udemy\projects-in-django>pipenv --support

$ pipenv --support

Pipenv version: '2018.7.1'

Pipenv location: 'C:\\Users\\jerry\\AppData\\Roaming\\Python\\Python37\\site-packages\\pipenv'

Python location: 'c:\\python\\python37\\python.exe'

Other Python installations in PATH:

  • 3.7: C:\Python\Python37\python.exe

  • 3.7.0: C:\Python\Python37\python.exe

  • 3.7.0: C:\Windows\py.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.0',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.17134',
 'python_full_version': '3.7.0',
 'python_version': '3.7',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPOSE_CONVERT_WINDOWS_PATHS
  • COMPUTERNAME
  • COMSPEC
  • DOCKER_CERT_PATH
  • DOCKER_HOST
  • DOCKER_MACHINE_NAME
  • DOCKER_TLS_VERIFY
  • DOCKER_TOOLBOX_INSTALL_PATH
  • DRIVERDATA
  • FPS_BROWSER_APP_PROFILE_STRING
  • FPS_BROWSER_USER_PROFILE_STRING
  • HOME
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • MOZ_PLUGIN_PATH
  • NO_PROXY
  • NUMBER_OF_PROCESSORS
  • ONEDRIVE
  • OS
  • PATH
  • PATHEXT
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PROMPT
  • PSMODULEPATH
  • PUBLIC
  • SESSIONNAME
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • VBOX_MSI_INSTALL_PATH
  • WINDIR
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Python\Python37\;C:\Python\Python37\Scripts\;C:\Users\jerry\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\Docker Toolbox;C:\Users\jerry\AppData\Local\Programs\Microsoft VS Code\bin;c:\users\jerry\bin;C:\Program Files\CMake\bin;c:\users\jerry\appdata\roaming\python\python37\scripts

Contents of Pipfile ('C:\Users\jerry\d\udemy\projects-in-django\Pipfile'):

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "*"

[dev-packages]
pylint = "*"
"flake8" = "*"

[requires]
python_version = "3.7"

Contents of Pipfile.lock ('C:\Users\jerry\d\udemy\projects-in-django\Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "cc0ee0b89a1b137b62bc674b52f4f9dcabac8fd14a6dc029fff80a7a638eb8cd"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "django": {
            "hashes": [
                "sha256:04f2e423f2e60943c02bd2959174b844f7d1bcd19eabb7f8e4282999958021fd",
                "sha256:e1cc1cd6b658aa4e052f5f2b148bfda08091d7c3558529708342e37e4e33f72c"
            ],
            "index": "pypi",
            "version": "==2.1.1"
        },
        "pytz": {
            "hashes": [
                "sha256:a061aa0a9e06881eb8b3b2b43f05b9439d6583c206d0a6c340ff72a7b6669053",
                "sha256:ffb9ef1de172603304d9d2819af6f5ece76f2e85ec10692a524dd876e72bf277"
            ],
            "version": "==2018.5"
        }
    },
    "develop": {
        "astroid": {
            "hashes": [
                "sha256:292fa429e69d60e4161e7612cb7cc8fa3609e2e309f80c224d93a76d5e7b58be",
                "sha256:c7013d119ec95eb626f7a2011f0b63d0c9a095df9ad06d8507b37084eada1a8d"
            ],
            "version": "==2.0.4"
        },
        "colorama": {
            "hashes": [
                "sha256:463f8483208e921368c9f306094eb6f725c6ca42b0f97e313cb5d5512459feda",
                "sha256:48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1"
            ],
            "markers": "sys_platform == 'win32'",
            "version": "==0.3.9"
        },
        "flake8": {
            "hashes": [
                "sha256:7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0",
                "sha256:c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37"
            ],
            "index": "pypi",
            "version": "==3.5.0"
        },
        "isort": {
            "hashes": [
                "sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af",
                "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
                "sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497"
            ],
            "markers": "python_version != '3.0.*' and python_version >= '2.7' and python_version != '3.3.*' and python_version != '3.1.*' and python_version != '3.2.*'",
            "version": "==4.3.4"
        },
        "lazy-object-proxy": {
            "hashes": [
                "sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33",
                "sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39",
                "sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019",
                "sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088",
                "sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b",
                "sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e",
                "sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6",
                "sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b",
                "sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5",
                "sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff",
                "sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd",
                "sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7",
                "sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff",
                "sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d",
                "sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2",
                "sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35",
                "sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4",
                "sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514",
                "sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252",
                "sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109",
                "sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f",
                "sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c",
                "sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92",
                "sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577",
                "sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d",
                "sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d",
                "sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f",
                "sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a",
                "sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b"
            ],
            "version": "==1.3.1"
        },
        "mccabe": {
            "hashes": [
                "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
                "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
            ],
            "version": "==0.6.1"
        },
        "pycodestyle": {
            "hashes": [
                "sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766",
                "sha256:6c4245ade1edfad79c3446fadfc96b0de2759662dc29d07d80a6f27ad1ca6ba9"
            ],
            "version": "==2.3.1"
        },
        "pyflakes": {
            "hashes": [
                "sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f",
                "sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805"
            ],
            "version": "==1.6.0"
        },
        "pylint": {
            "hashes": [
                "sha256:1d6d3622c94b4887115fe5204982eee66fdd8a951cf98635ee5caee6ec98c3ec",
                "sha256:31142f764d2a7cd41df5196f9933b12b7ee55e73ef12204b648ad7e556c119fb"
            ],
            "index": "pypi",
            "version": "==2.1.1"
        },
        "six": {
            "hashes": [
                "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
                "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
            ],
            "version": "==1.11.0"
        },
        "wrapt": {
            "hashes": [
                "sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6"
            ],
            "version": "==1.10.11"
        }
    }
}

C:\Users\jerry\d\udemy\projects-in-django>

@jerryasher
Copy link
Author

As a note, I'll point out that vscode allows the user to choose shells and Microsoft feels any of cmd.exe, PowerShell, Git Bash and Bash on Ubuntu are reasonable choices for a shell, thus it seems reasonable to expect all of these shells (with the possible exception of Bash on Ubuntu) should choose the same name and path for the virtualenv if the shells all have the same current dir

@uranusjr
Copy link
Member

Do you have WORKON_HOME set in either of the environments? I cannot reproduce this. Git Bash finds my virtual environment created with cmd.exe correctly.

@uranusjr
Copy link
Member

Ah, wait no, I take that back. WORKON_HOME only affects the environment’s parent directory, and in your case it is consistent. This is likely due to case sensitiveness. Could you run pwd in the Bash shell that has this problem and see whether it matches the one in cmd.exe?

@jerryasher
Copy link
Author

jerryasher commented Sep 18, 2018

Ah, wait no, I take that back. WORKON_HOME only affects the environment’s parent directory, and in your case it is consistent. This is likely due to case sensitiveness. Could you run pwd in the Bash shell that has this problem and see whether it matches the one in cmd.exe?

Aha! Very astute! So I found there was a case discrepancy in what git for windows bash pwd prints and what cmd.exe cd prints, and that's due to how I set HOME as an environmental variable for git for windows.

Bad:

$ echo $HOME
/c/users/jerry

Works:

$ echo $HOME
/c/Users/jerry

seen side by side with HOME set as /c/Users and not /c/users, the proper virtualenv is seen.

Seems that both cmd.exe and git for windows bash seem to be case insensitive with regards to directory names and cd? I don't know if that's something that pipenv on windows could or should check for, or warn about, but thank you for your help!

@uranusjr
Copy link
Member

I’m both happy and sad I guessed right :) Path casing on Windows is particularly difficult to get right, and we certainly didn’t do it right from the beginning, and unfortunately it is difficult to fix now (without breaking backward compatibility and making everyone angry, at least). I believe we made some changes recently to improve the situation, but I am not sure whether this is included. I’ll test this a bit and see if it is possible.

@uranusjr uranusjr added the Type: Enhancement 💡 This is a feature or enhancement request. label Sep 18, 2018
@uranusjr uranusjr self-assigned this Sep 18, 2018
@jerryasher
Copy link
Author

@uranusjr An addendum. The same problem (but worse?), or perhaps a different problem, but could you take a look at this?

Going back to basics, when I "correctly" set the $HOME such that pipenv wants to use the same dir for git for windows (mingw) as well as dos or powershell, that even so, pipenv shell doesn't activate the virtualenv, though I can use Scripts/activate to manually activate the shell.

This takes place in a mingw shell with no dot files being run....

$ which pipenv
/c/users/jerry/appdata/roaming/python/python37/scripts/pipenv
$ cd d/tdd
$ pipenv --venv
No virtualenv has been created for this project yet!
$ pipenv install
Creating a virtualenv for this project...
Pipfile: C:\Users\jerry\d\tdd\Pipfile
Using C:\Python\Python37\python.exe (3.7.0) to create virtualenv...
Running virtualenv with interpreter C:\Python\Python37\python.exe
Using base prefix 'C:\\Python\\Python37'
c:\python\python37\lib\site-packages\virtualenv.py:1041: DeprecationWarning: the imp modul                                                                      e is deprecated in favour of importlib; see the module's documentation for alternative use                                                                      s
  import imp
New python executable in C:\Users\jerry\.virtualenvs\tdd-yb0Po2xz\Scripts\python.exe
Installing setuptools, pip, wheel...done.
Setting project for tdd-yb0Po2xz to C:\Users\jerry\d\tdd

Virtualenv location: C:\Users\jerry\.virtualenvs\tdd-yb0Po2xz
Installing dependencies from Pipfile.lock (a7efcf)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
$
$
$ which python
/c/Python/Python37/python
$
$
$ pipenv shell
Launching subshell in virtual environment▒
$ which python
/c/Python/Python37/python
$ pipenv --venv
C:\Users\jerry\.virtualenvs\tdd-yb0Po2xz
$
$ source /c/Users/jerry/.virtualenvs/tdd-yb0Po2xz/Scripts/activate
(tdd-yb0Po2xz) $ which python
/C/Users/jerry/.virtualenvs/tdd-yb0Po2xz/Scripts/python
(tdd-yb0Po2xz) $
(tdd-yb0Po2xz) $
(tdd-yb0Po2xz) $ uname -a
MINGW64_NT-10.0 Dell5570 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys
(tdd-yb0Po2xz) $
(tdd-yb0Po2xz) $
(tdd-yb0Po2xz) $ pwd
/c/Users/jerry/d/tdd
(tdd-yb0Po2xz) $

@techalchemy
Copy link
Member

oh windows. This is what happens when we normalize things. Posix is case sensitive so we can't follow normalization rules like we do for win32, we need to figure out what the normalized win32 path would be and see if the corresponding virtualenv exists first

@frostming
Copy link
Contributor

frostming commented Oct 30, 2018

The path case issue is settled in #3105 , but I guess the problem here is the path under cmd.exe differs from that of bash.exe.

Please try +refs/pull/3105/merge and see if this issue still exists.

@oz123 oz123 added the OS: Windows This issue affects the Windows Operating System. label Jan 23, 2022
@matteius
Copy link
Member

This is no longer an issue on the master branch.
cmd.exe:

Successfully created virtual environment!
Virtualenv location: C:\Users\matte\.virtualenvs\pipenv-4963-oaRoupN9

Git shell:

~/Projects/pipenv-triage/pipenv-4963
$ pipenv sync
Installing dependencies from Pipfile.lock (823e27)...
  ================================ 0/0 - 00:00:00
All dependencies are now up-to-date!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Windows This issue affects the Windows Operating System. Type: Enhancement 💡 This is a feature or enhancement request.
Projects
None yet
Development

No branches or pull requests

6 participants