Skip to content

The virtualenv activate script does not correctly detect the Windows Git Bash shell #125398

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

Closed
julienp opened this issue Oct 13, 2024 · 1 comment · Fixed by #125399
Closed

The virtualenv activate script does not correctly detect the Windows Git Bash shell #125398

julienp opened this issue Oct 13, 2024 · 1 comment · Fixed by #125399
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@julienp
Copy link
Contributor

julienp commented Oct 13, 2024

Bug report

Bug description:

When using the virtualenv activate script in Git Bash for Windows, the environment is not correctly detected and paths are not converted.

This results in $PATH being set to something like D:\a\github-actions-shells\github-actions-shells\venv/Scripts:..., instead of /d/a/github-actions-shells/github-actions-shells/venv/Scripts.

Prior to #112508, the detection used $OSTYPE, which reports msys in Git Bash for Windows, however uname returns MINGW....

This is a regression in Python 3.13.0

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

@julienp julienp added the type-bug An unexpected behavior, bug, or error label Oct 13, 2024
@picnixz picnixz added topic-venv Related to the venv module stdlib Python modules in the Lib dir labels Oct 13, 2024
github-merge-queue bot pushed a commit to pulumi/pulumi that referenced this issue Oct 14, 2024
Run 3.13 in CI

Debugpy now supports 3.13
https://github.com/microsoft/debugpy/releases/tag/v1.8.7

There's an issue with virtualenvs when running in Git Bash for Windows
python/cpython#125398, we have a workaround
for the impacted tests.

Ref #17484
vsajip pushed a commit that referenced this issue Oct 19, 2024
…under Windows (GH-125399)

* Convert paths in venv activate script when using Git Bash under Windows

With #112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead.

However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`).

This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`.

Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 19, 2024
… Bash under Windows (pythonGH-125399)

* Convert paths in venv activate script when using Git Bash under Windows

With python#112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead.

However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`).

This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`.

Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
(cherry picked from commit 2a378db)

Co-authored-by: Julien <julien@caffeine.lu>
vsajip pushed a commit that referenced this issue Oct 19, 2024
@y5c4l3
Copy link
Contributor

y5c4l3 commented Oct 21, 2024

uname -o seems a more semantic and stable candidate for MSYS2 detection, as well as Cygwin. Since it's merged already, I'll leave the outputs here only for reference.

image
image

ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
… Bash under Windows (pythonGH-125399)

* Convert paths in venv activate script when using Git Bash under Windows

With python#112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead.

However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`).

This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`.

Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants