Hi,
I am sorry if this is not the proper place for this question.
The tools (like cp, mv, cat, etc.) work smoothly under the MSYS2 shell, but when I try to launch them under Windows _cmd_, they will take too long to response. For example, open Windows cmd console and cd to %MSYS2_ROOT%usrbin, input mv and hit enter, it takes almost 10 seconds to output the help info of mv...
I am new to MSYS2 and it is really great, I just want to use it everywhere, not only under MSYS2 shell, is it possible? Or, is there any workaround to achieve this?
Thanks,
Kelvin
It's a reasonable place yes.
I'm not seeing this:
C:msys64usrbin>cmd /v:on /c "echo !TIME! & mv & echo !TIME!"
13:51:07.24
mv: missing file operand
Try 'mv --help' for more information.
13:51:07.33
.. so that took < 1/10th of a second.
can you execute do:
strace mv and post the results to paste.kde.org please.
I tested this also and got similar results to @mingwandroid, super fast:
9:51:09.52
mv: missing file operand
Try 'mv --help' for more information.
9:51:09.54
Running the command directly in the console (i.e. without extra cmd invocation) gives the same kind of results.
Thanks for your quick response, I was wondering if it is a common issue, but now I am happy that it is not.
This is the output with time consumed:
D:\SDTs\MSYS64\usr\bin>cmd /v:on /c "echo !TIME! & mv & echo !TIME!"
10:36:19.81
mv: missing file operand
Try 'mv --help' for more information.
10:36:32.99
and then I run strace -o mv.log mv to trace it, the output _mv.log_ is pasted at http://paste.kde.org/p7dqv25nm, seems it takes too much time to fetch account from windows...
Cygwin (which msys2 is based on) recently removed the need for /etc/passwd and /etc/group and instead reads account information directly from Windows database.
Hypothesis:
The accounts are read and cached in the DLL, since you start from cmd directly, program load dll, execute, die and dll is unloaded. So each time you are re-reading accounts which seems very long on your case (probably because you are over LDAP and there is a lot of information).
Hypothesis test:
Start an msys2 bash shell using msys2_shell.bat or any other means that load msys2 dll and keep it open. Then start a normal cmd one and re-run test. If all I said is correct, time should be back to normal. (I could have a misunderstanding of DLL loading)
If I'm right, reporting this to Cygwin project with details of your configuration could probably help them diagnose better and see if it's expected or not.
Hope this helps.
Matt
I wonder if Cygwin would consider caching this information for people who run into this very slow account query ..
@maoueh Thanks for your advice, I keep msys2 shell always open, but the command in _cmd_ console still gets very slow. However, the command run in msys2 shell is super fast, I think it must have cached the accounts, but maybe it is not in the DLL...
@mingwandroid Thank you too, I will ask Cygwin project for more information.
I see the same problem for a few weeks now on my work machine in our corporate network where we have an Active Directory with a very elaborated group membership structure, which means I'm a member in tons of groups and to start a MSYS2 shell takes minutes (5-10 min), which makes it unusable in such an environment. To be honest, this is a weak design/implementation by the cygwin folks.
@juergenpf Checkout this issue https://github.com/Alexpux/MSYS2-packages/issues/138 where users seems to have workaround the problem by commenting db in their nsswitch.conf file.
Not sure if this will work on your case, good luck.
@maoueh Thanks for the tip, it did solve the issue for me, but with a small tweak, which I'd written on #138's page.
Yeah, after disable db in nsswitch.conf, those commands work great also in Windows cmd! Also, there is a great article describes this problem and gives a solution: http://bjg.io/guide/cygwin-ad/.
Thanks for all of you, closing the long live issue now.
@kelvinh
Thank you, the article saved me. I also got issue and after comment the db option. It works again
@vnluc Glad it works. :)
@kelvinh excuse the stupid question... where is nsswitch.conf located on Windows?
@lanzkron
It is in "etc" folder in your installation.
@lanzkron /etc/nsswitch.conf under MSYS2 installation folder.