sudo geany throws fatal error [duplicate]

I really like the Geany text editor, and would like to use it instead of gedit for all text editing. However, every time I try to launch Geany from the terminal using sudo geany file.conf, I get this error:

(geany:10203): Geany-WARNING **: Geany tried to access the Unix Domain socket of another instance running as another user.

This is a fatal error and Geany will now quit.

I am the only user logged in to the machine. There are no instances of Geany already running when I type that command into the terminal. Geany has no trouble launching from the command line if I don't use a sudo. I also don't have any trouble running Gedit with elevated privileges; the command sudo gedit file.conf functions flawlessly.

What is going on here? How can I fix this so that I can edit text files in Geany with elevated privileges?


Try deleting this file:

sudo -H rm ~/.config/geany/geany_socket_*

if you want you can move them to some folder temporarily.