Terminal prompt is very slow to show in git folders under WSL2
umberleigh opened this issue · 5 comments
Describe the bug
When opening a terminal or changing to a directory that's using git, it can take around 1 minute to return a terminal prompt when using WSL2 on windows.
To Reproduce
Steps to reproduce the behavior:
- in windows 10, under WSL2 and Ubuntu 20.04 LTS, open a terminal
- cd into a directory under version control with git
- wait (a long time) to get a prompt so you can do anything
Expected behavior
I should get a prompt quickly like under any other directory
Hi,
I had the same problem. I've searched on internet and I've found out that this is a known problem whit WSL2.
In fact, windows git version is much faster than linux git version.
At the moment the best solution that I've found is to create an alias in .bashrc
file like this:
alias git='git.exe'
I know that is a stupid fix, but it works.
Hope this can help you
Thanks for your help @bongijo
After reading through this issue and this one it's clear it's an issue with WSL2 being slow when accessing windows NTFS volumes and not the fault of Synth Shell.
I followed this suggestion from this issue which works and means you can still use linux git for everything outside of /mnt:
I came up with a dumb but useful workaround for this specific case. It works because windows git is faster against ntfs and I don't need any linux specific things for git at least.
I put this in my bash
.profile
# checks to see if we are in a windows or linux dir function isWinDir { case $PWD/ in /mnt/*) return $(true);; *) return $(false);; esac } # wrap the git command to either run windows git or linux function git { if isWinDir then git.exe "$@" else /usr/bin/git "$@" fi }
Feel free to pullrequest a change to Synth Shell Greeter to use the correct version of git ;)
Thanks @andresgongora - would synth-shell-greeter/synth-shell-greeter/synth-shell-greeter.sh be the appropriate place to add this?
Woops. By bad. I meant to say synth-shell-prompt, not greeter. So it would be within synth-shell/synth-shell-greeter/synth-shell-greeter.sh
. Feel free to add it in there and we'll figure out together where it fits best - maybe within one of the git related functions at the top of the script?