14
votes

I have been using Cygwin commands from my Windows CMD prompt for several months without problems. Within the past few days, every time I call a Cygwin command (ls for example), the command takes several seconds to "load" before it actually runs. If I try the same command from within a bash prompt, it runs ("loads") immediately.

The Cygwin FAQ mentions that network drives in PATH may cause problems, so I've tried some permutations of my PATH variable and network connectivity. Below, "full PATH" means my original path setting; "short PATH" means the path with only the Cygwin bin directory. Times are reported through the time command.

Timing results for ls

Connected to network:

  • Run ls within bash: 0.124 s
  • Run ls within CMD (full PATH): 41.29 s
  • Run ls within CMD (short PATH): 38.56 s

Disconnected from network:

  • Run ls within bash: 0.125 s
  • Run ls within CMD (full PATH): 0.17 s
  • Run ls within CMD (short PATH): 0.19 s

Results for cygcheck

I ran cygcheck -s and noticed:

Warning: There are multiple cygwin1.dlls on your path

although this may be due to running cygcheck from within Cygwin's bin directory. I completely uninstalled and reinstalled Cygwin and still see the same issue.

Results from netstat

I ran netstat -a -n before executing Cygwin's ls and after execution (while it is stalled). I did this several times and found one line from each run that appeared consistently during the delay:

  UDP    127.0.0.1:55030        *:*                    

The port number changed from test to test.

strace results

I ran Cygwin's strace on the ls command. Most of the delay is spent in calls such as:

11685  886560 [main] ls 10020 pwdgrp::fetch_account_from_windows: line: <xxxx>

and

12684  899244 [main] ls 10020 cyg_ldap::fetch_ad_account: No entry for (objectSid=\00\00\00\00) in xxxx DC=xxxx,DC=xxxx,DC=xxxx
1
This is a work computer; I cannot disable antivirus (even to test). - tbhartman
I have verified that all directories in my unaltered PATH exist and are local. - tbhartman
So now disconnecting from the network makes everything faster? That isn't consistent with the results you originally posted. Consider using Process Monitor (available from the MS web site) to examine what the process is doing during the long delay. - Harry Johnston
@HarryJohnston, yes, I must have been doing something wrong the first time. It is also only when I am connected to my company's network (so from home, when connected via VPN). Perhaps it is antivirus related. I'll try Process Monitor. - tbhartman
Most corporate networks that provide a VPN tunnel disallow split tunneling (i.e., default route gets changed corporate VPN endpoint when tunnel is connected). - Bill_Stewart

1 Answers

23
votes

A section in Cygwin's FAQ addresses slow startup times. Cygwin recently changed to using Active Directory lookups for authentication, rather than using flat files. Changing the defaults in /etc/nsswitch.conf from

passwd:   files db
group:    files db

to

passwd:   files
group:    files

skips the AD lookup. My Cygwin commands are now speedy again.