-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Bug: GCM Misidentifies Docker Containers Running on WSL2 Due to /proc/version #1813
Comments
All attempts to start Windows executables from So the only reliable solution would be to:
|
@becm |
@vinitsiriya let's assume the above error is triggered due to calling GetWebBrowserAvailable.
So correctly catching the
should redirect to the native This would still not cover the issue that hoping we can launch a Windows-Bowser will get us anything from within a Docker runtime… So as a summary,
|
Description Git Credential Manager (GCM) incorrectly identifies Docker containers running on WSL2 as WSL distributions. This is caused by
/proc/version
in the container inheriting WSL-related strings (WSL2
,microsoft
) from the underlying WSL2 host kernel. As a result, GCM incorrectly applies WSL-specific logic and attempts to invoke Windows interop tools (e.g.,powershell.exe
), which are not available in Linux-native Docker containers.This results in failed Git operations inside the Docker container, even when the container is a full Linux environment.Steps to Reproduce
Prerequisites:
Docker Desktop is installed on Windows and configured to use WSL2 as the backend.
GCM for Linux is installed inside the Docker container.
Steps:
Run a desktop-enabled container like
linuxserver/rdesktop
:Inside the container, run:
Output :
This indicates the container inherits the WSL2 kernel from the host.
Inside the container:
Run:
Observe the Error :
Current Behavior
Detection Logic : GCM incorrectly detects the Docker container as a WSL distribution because
/proc/version
contains WSL2-related strings (WSL2
,microsoft
).Interop Issue : GCM tries to invoke Windows tools (e.g.,
powershell.exe
), which do not exist in the container.Result : Git operations relying on GCM fail inside the container.
Expected Behavior GCM should recognize the Docker container as a Linux-native environment and avoid invoking Windows interop tools. It should use Linux-native tools like
pass
or other credential helpers configured for Linux.Root Cause The problem lies in the current WSL detection logic in the
WslUtils.GetWslVersion
method, which checks for WSL-related strings in/proc/version
but does not account for Docker containers that inherit these strings from the WSL2 host.Current Logic:
This does not differentiate between actual WSL distributions and Docker containers running on WSL2.
Proposed Fix
/proc/1/cgroup
or/proc/self/cgroup
. If the environment is containerized (e.g.,docker
,containerd
), bypass WSL detection:GCM_DISABLE_WSL_SUPPORT
:Add an environment variable to explicitly disable WSL detection. This allows users to force Linux-native behavior in ambiguous environments. For example:
export GCM_DISABLE_WSL_SUPPORT=1
Default to Linux-Native Tools for Containers :
If
/proc/version
contains WSL2-related strings but the environment is containerized, GCM should default to Linux-native behavior instead of invoking Windows tools.Proposed New Logic :
Additional Context
This issue primarily affects:
Docker Containers running on WSL2 backends (e.g., Docker Desktop with WSL2 integration).
Linux-native workflows where users expect GCM to operate without invoking Windows interop tools.
The text was updated successfully, but these errors were encountered: