Ubuntu – How to diagnose “There was an error launching the application”

desktoplauncher

I created a my-app.desktop file for a program I wrote. When I double-click it, I get the error message "There was an error launching the application". How can I get more detailed information about what the problem is?

I saw a reference to a "details" section of the dialog box, but there is nothing like that present in the one I see. If I were on my Mac, I'd open the Console app to see if any errors were logged, but I haven't learned of anything similar on Ubuntu.

(Note that unlike other similarly-titled questions, I am not asking what's wrong with this particular .desktop file; I want to know how to find out in general.)

Best Answer

Here's a trick you can use. Create a wrapper script for your application that will launch it and capture the error output:

#!/usr/bin/env bash

## Launch 'yourapp' and capture its standard error output
/path/to/yourapp 2>~/myapp.log

Save that as ~/foo.sh and make it executable with chmod +x ~/foo.sh. Now, point your desktop launcher to it instead. Something like:

[Desktop Entry]
Version=2.0
Type=Application
Exec=/home/kevin/foo.sh
Terminal=true
Comment=My app!

That will redirect any error messages to ~/myapp.log and you can examine them at your leisure. You can use 2>>~/myapp.log if you want successive error messages to be appended to the file instead of overwriting it.


As an aside, the reason that the $PATH is different is because you are probably setting your $PATH in ~/.bahsrc which is not read by the graphical environment. It is also a bad idea since the $PATH will be set every time you open a new terminal and that is needless overhead. Use ~/.profile for this instead. For more details on which files are read when see here and for more on which file should be used for what, see here.