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

Terminal prompt is very slow to show in git folders under WSL2 #199

Closed
umberleigh opened this issue Mar 26, 2021 · 5 comments
Closed

Terminal prompt is very slow to show in git folders under WSL2 #199

umberleigh opened this issue Mar 26, 2021 · 5 comments
Labels

Comments

@umberleigh
Copy link

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:

  1. in windows 10, under WSL2 and Ubuntu 20.04 LTS, open a terminal
  2. cd into a directory under version control with git
  3. 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

Screenshots
image

@umberleigh umberleigh added the bug label Mar 26, 2021
@bongijo
Copy link

bongijo commented Mar 26, 2021

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

@umberleigh
Copy link
Author

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
}

@andresgongora
Copy link
Owner

Feel free to pullrequest a change to Synth Shell Greeter to use the correct version of git ;)

@umberleigh
Copy link
Author

Thanks @andresgongora - would synth-shell-greeter/synth-shell-greeter/synth-shell-greeter.sh be the appropriate place to add this?

@andresgongora
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants