2

When I'm connected to my company VPN, the "Git bash here" takes 1 minute to start. "ls" command or any other MSYS2 linux comand takes 1 minute as well.

If I'm not connected to the VPN, it all works just fine.

When connected to VPN, I execute "bash" from windows 10 cmd line, and it takes 1 minute to open the bash. I close the bash and type "bash" again and the command executes immediately. But if i wait for 2 or 3 minutes and execute "bash", it takes again 1 minute to execute.

I have searched and tried many solutions, but none worked for me: I tried this: Git Bash is extremely slow on Windows 7 x64 and this https://cygwin.com/faq.html#faq.using.startup-slow, among others, but didn't work.

I suspect on a DNS problem when VPN is active. But I tried changing DNSs by hand and didn't solve the problem.

I also tested MSYS2 stand-alone, version msys2-x86_64-20210228, and removed GIT: Same problem! with the bash or any other MSYS2 command. The bash window opens immediately if not connected to the VPN, but it takes 55 seconds first time after connecting to VPN.

My system:

  • Git version 2.31.1.windows.1
  • Windows 10 (10.0.19041 Build 19041)
  • msys2-x86_64-20210228
piedramania
  • 103
  • 9
  • 1
    It would help others if you can mention the versions of git and your OS – Asif Kamran Malick Apr 05 '21 at 13:28
  • If computer is offline it all works correctly. This didn't help either: https://stackoverflow.com/questions/66716650/launching-msys2-mingw-64-is-very-slow-when-the-computer-is-offline – piedramania Apr 05 '21 at 13:59
  • where are your git remotes hosted? e.g GitHub, private company servers, GitLab, etc. what protocol do you use for authenticating to the server? i have seen Git-Bash support GitHub. i am not sure, but is it possible that Git-Bash is trying to authenticate with GitHub at startup--i think there is an independent authentication/credential helper add-on thing now; and your company's VPN might be blocking GitHub resulting in it being slow? (disclaimer: i don't use Windows. speaking based on observing others who do) – kevinnls Apr 05 '21 at 14:37
  • Does the window start ? Can you change your `$HOME/.bashrc` and start with `echo "Please wait, executing .bashrc."` ? – Walter A Apr 05 '21 at 16:08
  • Can you check if antivirus becomes active when you activate VPN ? – Philippe Apr 05 '21 at 16:17
  • I deactivate the antivirus. Same problem! – piedramania Apr 06 '21 at 05:36
  • If I change the .bashrc to the text `echo "Please wait, executing .bashrc"` and execute bash.exe from command line, the text lasts for 1 minute to appear, just before the bash starts. So whatever is creating the delay, it is before reading (or executing) .bashr – piedramania Apr 06 '21 at 06:11

1 Answers1

4

I found the solution here: https://gist.github.com/k-takata/9b8d143f0f3fef5abdab, solution 2:

For Git for Windows:

  1. Connect to VPN
  2. update password and group while connected to the VPN. Open a cmd line as admin, go to C:\Program Files\Git\usr\bin

and execute this (since your are connected to VPN, it might takes a while):

> mkpasswd -l -c > ../../etc/passwd
> mkgroup -l -c > ../../etc/group
  1. Then, comment out the "db" in the /etc/nsswitch.conf file:

From the command line with admin, execute

> notepad ..\..\etc\nsswitch.conf

and comment out the "db":

# Begin /etc/nsswitch.conf
passwd: files #db
group: files #db

For MSYS2:

  1. Connect to VPN
  2. update password and group while connected to the VPN. From the MSYS bash console

execute this:

$ mkpasswd -l -c > /etc/passwd
$ mkgroup -l -c > /etc/group
  1. Then, comment out the "db" in the /etc/nsswitch.conf file:

C:\msys64\etc\nsswitch.conf:

# Begin /etc/nsswitch.conf
passwd: files #db
group: files #db

In the link there are some comments to this solution:

  • This will only work for the user that executes mkpasswd/mkgroup
  • /etc/nsswitch.conf gets replaced on every upgrade of Git for Windows or MSYS2
piedramania
  • 103
  • 9
  • In a link given in the questions gives a similar solution, but it is not well explained how to do the `mkpasswd` and `mkgroup` update – piedramania Apr 06 '21 at 08:01
  • For any reason the passwd and group files generated with MSYS and Git are similar, but not the same – piedramania Apr 06 '21 at 08:54