Problem
Git push, pull, and fetch operations on WSL2 projects fail in JetBrains IDEs (IntelliJ IDEA, PhpStorm, GoLand, PyCharm, and others) with the following error:
/mnt/c/Users/user/AppData/Local/JetBrains/<IDE>/tmp/intellij-ssh-askpass-wsl-Ubuntu.sh: 3: /mnt/c/Users/user/AppData/Local/JetBrains/Toolbox/apps/<IDE>/ch-0/<build>/jbr/bin/java.exe: Exec format error
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
The same git push / git pull commands run successfully from a standalone WSL terminal or Windows terminal. The failure is reproduced consistently for both GitHub and Bitbucket remotes.
Cause
WSL2 uses the Linux kernel binfmt_misc feature (Win32 interop) to recognize and execute Windows .exe binaries from inside the WSL distribution. Following certain Windows or WSL updates, the WSLInterop registration can be lost or become inactive.
When the IDE performs a git remote operation, it launches an SSH askpass helper that invokes the bundled java.exe located on the Windows filesystem (/mnt/c/...). Without an active WSLInterop registration, WSL cannot execute the Windows binary and reports Exec format error. The SSH credential prompt never runs, so authentication fails with Permission denied (publickey).
This is a Windows/WSL configuration problem, not a defect in the IDE.
Resolution
Restore the WSLInterop binfmt registration by creating a persistent configuration file inside the WSL distribution.
-
Open a WSL terminal.
-
Create the file
/usr/lib/binfmt.d/WSLInterop.confwith the following content::WSLInterop:M::MZ::/init:PFFor example:
sudo sh -c 'echo ":WSLInterop:M::MZ::/init:PF" > /usr/lib/binfmt.d/WSLInterop.conf' -
Reload the binfmt registrations:
sudo systemctl restart systemd-binfmt -
Retry the git remote operation in the IDE.
If the fix does not persist after WSL restart
Ensure systemd is enabled in the WSL distribution. Add the following to /etc/wsl.conf:
[boot]
systemd=true
Then restart WSL from a Windows terminal:
wsl --shutdown
After restart, the /usr/lib/binfmt.d/WSLInterop.conf file is reloaded automatically by systemd-binfmt.
Additional Information
- Confirmed across multiple JetBrains IDEs (IntelliJ IDEA, PhpStorm, GoLand, PyCharm) on Windows 10 and Windows 11 with WSL2.
- Tracked upstream in IJPL-77163, resolved as Third Party Problem (WSL/Windows-side configuration).
- Microsoft tracks the underlying WSL behavior in the WSL repository.
Comments
0 comments
Please sign in to leave a comment.