Friday, May 3, 2013

Slow Startup of Cygwin Bash

When on Windows, I never use another terminal/shell than MinTTY/CygWin Bash. So I was heavily harmed by a problem that started quite some time ago: Suddenly, when I opened MinTTY, it took 10 seconds or so, before the bash prompt became visible. Today, I finally discovered the culprit by reading another post. As you posssibly know, there is a directory /etc/profile.d containing scripts that are executed when a login shell is starting. Now, one of these scripts, called is extremely slow. You can try for yourself:
$ time . /etc/profile.d/

real    0m8.908s
user    0m1.402s
sys     0m7.310s

In other words, solving the issue for me was as simple as renaming this script:
$ mv /etc/profile.d/ /etc/profile.d/
Voila! My MinTTY opens immediately again. Update: The above time command is only slow when the script is being executed for the first time. In other words, if your bash was starting slow due to executing it, then you might see a result like this:
$ time . /etc/profile.d/

real    0m0.000s
user    0m0.000s
sys     0m0.000s


Anonymous said...

I've been sooooo frustrated with the slow bash startup time. Your solution reduced my bash startup from about 8 seconds to about 2 seconds. Thanks!

Anonymous said...

thank you, Jochen!
You've solved an issue that has bugged me for quite while.

Good day!

Anonymous said...

the real problem is too many files in "/etc/bash_completion.d".

remove anything you don't want will solve this problem.