I have used cygwin and emacs for a long time and there have always been problems integrating. xemacs under cygwin worked perfectly but require xwindows running which was unpleasant. Then I added git bash to the mix.
Now if you count, I have 4 separate unix implementations under windows:
cygwin
Qt (which runs mingw somewhere in there)
git bash
MSYS64
with emacs running native on windows.
I want to know if I can consolidate and delete some of these tools. It seems ludicrous that cygwin and MSYS2 have git. Then why have a separate git bash? From what I read, git is running in MSYS2 anyway.
But I am highly suspicious. In the past, cygwin was NOT the same as mingw. There were two big bugs I found -- one is the runtime libraries, which on mingw used the native libraries. So even though the compiler was the same, compiling a program with long double yielded a program that did not work.
I tried that now, and it works in MSYS2. That could be because they are using all gnu libraries, or because microsoft has updated.
Threading also did not work in mingw but did in cygwin. I just tested with the following C++ code in MSYS2-64:
#include <thread>
#include <iostream>
#include <unistd.h>
using namespace std;
void f() {
for (;;) {
cout << "yo!\n";
// sleep(1);
}
}
void g() {
for (;;) {
cout << "ho!\n";
// sleep(2);
}
}
int main() {
thread t1(f);
thread t2(g);
t1.join();
t2.join();
cout << "Done!\n";
return 0;
}
Running under emacs, as installed in MSYS2, the job does not stop (I have to kill the shell). It does work on the command line. If I uncomment the sleep calls, it hangs both in MSYS2 bash and an emacs command shell.
then there is the issue with git.
git bash is using /c/Users/myuser as the directory to store .ssh. It works
When I echo $HOME under cygwin, it shows /c/Users/myuser but it still tries to use /home/myuser, which does not exist, which means that .ssh directory does not exist, so it fails. So I can build in cygwin, but have to push in git bash which is annoying. I cannot buidl in git bash because it does not have a full dev environment.
MSYS2 claims that HOME is /c/Users/myuser but when trying a git push it says the same error:
Could not create directory '/home/myuser/.ssh'. So somewhere inside there, it still has hardcoded the notion that .ssh should be in /home/myuser as opposed to c:/Users/myuser.
What's worse, in cygwin there is a /home directory and I seem to recall it by default created /home/myuser though it is not there now. in MSYS2, there is NO DIRECTORY /home, and I wonder if I should create one.
I could create one symbolically linked to c:/Users/myuser, if that works under windows? I just tried this:
mkdir /home/
ln -s /c/Users/myuser /home/myuser
The shell hung. That's not good! I killed the shell and ran again. Somehow there was a directory there /home/myuser (but not my symbolic link). How it was generated, I do not know. But I create a symbolic link .ssh inside, and now it works. But it makes me nervous, because I don't understand what is happening.
MSYS64 has huge advantages over cygwin. There is a package manager, it installs much faster, it is vastly smaller than cygwin. The compiler is newer.
There are still some problems with emacs and MSYS64 which I will ask in a separate question, but since it seems to work really well, the question is, can I afford to get rid of the other ones? I am looking into this to see whether I can ask students to install this for C++ and data structures classes, so I definitely want threading and compilation to work. The errors I can't resolve thus far include:
Is there a workaround for threading
What is happening with /home/user? I made it work, but that could bite later on, it has to be understood.
Are there any other compataibility issues lurking?
The thread problem still appears to be there.
In summary, is there any way to use git in MSYS2, can I safely get rid of git and cygwin? Or will there be reasons to keep cygwin around? Do I have to keep git bash around separately?