Score:0

Why is it that about 50% of the time, when I start ubuntu under WSL 2 (Windows 10) my .bash_profile doesn't launch the applications

cn flag

I have my .bash_profile configured to launch emacs, and usually the first time it tries to, nothing happens, the command shows up in my "log file" but I don't get an emacs, but then if I start another copy, it launches emacs. It doesn't matter whether I close the first session or not for the second attempt to work.

Here are the relevant commands from my .bash_profile. They are essentially the end of it.

echo emacs --debug-init -mm >> ~/emacs-messages/inside-emacs
emacs --debug-init -mm
echo sleep 1 >> ~/emacs-messages/inside-emacs
sleep 1
echo emacs should be running now >> ~/emacs-messages/inside-emacs
echo ps -ax >> ~/emacs-messages/inside-emacs
ps -ax >> ~/emacs-messages/inside-emacs

Now, when it works, I see the result of the first echo line in the file and emacs is running. When it doesn't I see all the echo lines in the file and there is no emacs process running. I can then start emacs manually with the same command as in the .bash_profile, but for some reason bash has not let me start it automatically. By the way, I execute these commands only when ${DISPLAY} is set (and it is always ":0". My .emacs file also does logging and I don't see any of those messages when emacs doesn't start.

The problem only manifests itself under WSL 2, but doesn't matter which version of Ubuntu (i.e. 18.04 or 20.04) that I use. All of this is on Windows 10 pro, build 21390.co_release.210512-1658.

Also there is no effect (on the bad case) of backgrounding the emacs command, i.e.

emacs --debug-init -mm &

Same issue. It does get the sleep and other messages to appear in my log file in the good case, but that I don't care about. There is nothing interesting in that case, other than I see a running emacs process in the ps output.

If there is something else I should be logging to get information, I would appreciate knowing that also.

terdon avatar
cn flag
You need to see why it fails. Capture the error output by changing your emacs invocation to `emacs --debug-init -mm 2>> ~/emacs-messages/inside-emacs` and check the file for error messages and add what you find to your question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.