piedramania
piedramania

Reputation: 160

"Git Bash here" takes too long to start (also MSYS2 bash terminal)

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:

Upvotes: 2

Views: 2119

Answers (1)

piedramania
piedramania

Reputation: 160

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

Upvotes: 5

Related Questions