I've tested the same scenario on brand new git instalaltion on Windows 10 and got the same behavoir.
Indeed, renaming or removing .bash_profile
in C:\Users\<username>
folder removes bash startup delays. But for some time.
Of course, I had HOME
env var set.
After restating Terminal and cmd (I tested form both) usually the first run of bash in shell is still slow but starts quicker after some exit/start cycles.
Then I suspected the .bashrc
file which is located in the ~/ directory (/home/<username>)
of the linux distribution because by default it is 3.7K and may cause some slowness.
Renaming it I've got the same behavior: if I run bash multiple times in the same cmd/terminal (which uses WSL under the hood) then consequent run become very fast exept the first one.
I've also tested running bash without profile which was slwo the same way:
Measure-Command { wsl -e bash -noprofile -norc -c "echo Hello" }
TotalSeconds : 29,3953657
The consequent run in the same window was quick:
Measure-Command { wsl -e bash -noprofile -norc -c "echo Hello" }
TotalSeconds : 0,2136513
So, I believe the real issue is how wsl works with memory in W10 and the page file, and/or caches data for emulation.
Also you should notice that running bash command you actually call wsl, not the git bash:
C:\Users\user>where bash
C:\Windows\System32\bash.exe
C:\Users\user\AppData\Local\Microsoft\WindowsApps\bash.exe
But the git bash is actually called from here:
"C:\Program Files\Git\git-bash.exe" --cd-to-home
.bash_profile
, you are no longer starting ZSH. I suggest you investigate ZSH startup performance.