Audacity would silently exit each time after running

I’m using Linux for music production for many years, and I consider myself very experienced with Linux in general at this point.
Nevertheless for the past few days I’ve been unable to run Audacity at all.

I didn’t know what is wrong, because running it in the terminal didn’t show anything useful:

$ audacity 

(Audacity:5274): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()                                                                                                                                                    
                                                                                                                                                                                                                                             
(Audacity:5274): Gtk-WARNING **: Unable to locate theme engine in module_path: "adwaita",                                                                                                                                                    
                                                                                                                                                                                                                                             
(Audacity:5274): Gtk-WARNING **: Unable to locate theme engine in module_path: "adwaita",

Today I’ve run it with gdb to finally find out.

(gdb) run
Starting program: /usr/bin/audacity 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

(Audacity:12711): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()

(Audacity:12711): Gtk-WARNING **: Unable to locate theme engine in module_path: "adwaita",

(Audacity:12711): Gtk-WARNING **: Unable to locate theme engine in module_path: "adwaita",
[Inferior 1 (process 12711) exited with code 0377]

This was surprisingly mysterious. Exit code 0377? This got me thinking…

It turned out it was painfully simple. Audacity exited because there was another instance already running on my system. How didn’t I know this?
I routinely suspend my system to RAM and resume it each day. I also use 6 virtual desktops for different activities and I had Audacity open on one of them, that I forgot about.

When I realized the source of the issue at first I thought that I shouldn’t not report this as a problem, as it was caused by my own stupidity - however I think there is a problem that should be addressed.
Audacity didn’t tell me this. Nothing would hint me that this is the reason why it doesn’t run. It was a pure incident that I have finally found out.

I would expect Audacity to at least spew something in the terminal like “Audacity is already running with PID XXXX. Exiting.”
That would have saved me quite some confusion.

A better solution would be for me to have Audacity quietly open a new project. This is what I wanted to do after all.

What do you think?

This is interesting - I’ve looked at the code, and it appears that Audacity “should” give an error message, but doesn’t. This was a surprise to me because I don’t recall that ever working (though I don’t generally try starting Audacity when it is already running).

I may have more information later…

Definitely a bug here. Not sure at the moment if only on Linux (the code forks with different behaviour for Windows), but definitely a bug on Linux.

I’ve found the problem. Doesn’t happen on Windows, but could account for why we have been seeing a number of Mac users unable to launch Audacity (because it’s already running).

Audacity “should” handle this in rather a clever way. What should happen, (if not for the bug), is that if Audacity is already running, then the start-up command is piped through to the running instance before stepping backwards through the start-up sequence to cleanly exit the new evocation. If the new instance is unable to connect to the already running instance, then an error message is thrown.

The bug is, that if the Audacity command is given with no additional arguments, Audacity simply exits without attempting to call the running instance of Audacity, and because it has not attempted to call the running instance, the call does not fail, so no error message is produced and the new instance simply exits silently (with a non-zero return).

I’ve now made a fix, so this should be OK in the next release, provided that it does not cause problems on Mac (which I’ve not yet tested).