4

I am running Ubuntu 14.10 with XFCE. Since a few weeks, gedit is not launching any more as root (with gksu gedit).

Launching with my normal account works without problems. The problem is not gksu, as it does the same as sudo (I know, not recommended for GUI) or gksudo. pkexec gives a different error. However, other programs (e.g. eog) run fine with gksu!

When I run gksu gedit, I get the gksu password prompt, and after entering it, I see the circling mouse cursor for maybe half a minute, but no gedit window opens. No terminal output either.

Running pkexec gedit in a terminal gives:

bytecommander@AlkaliMetal:~$ pkexec gedit
gdk_mir_display_open
Failed to connect to Mir: Failed to connect to server socket: File or Path not found.

(gedit:3935): Gtk-WARNING **: cannot open display: 
bytecommander@AlkaliMetal:~$ 

Running gedit in a root terminal gives:

root@AlkaliMetal:/home/bytecommander# gedit

(gedit:24281): dconf-WARNING **: failed to commit changes to dconf: Failed to execute child process "dbus-launch" (No such file or directory)

** (gedit:24281): CRITICAL **: file log.c: line 975: unexpected error: Failed to execute child process "dbus-launch" (No such file or directory) (g-exec-error-quark, 8)

^C
root@AlkaliMetal:/home/bytecommander#

(The command doesn't terminate. I aborted it after a while with Ctrl+C)

I searched for the log.c file from the error message. The only one I found was /usr/share/gettext/intl/log.c. Strange is however, that this file only contains 126 lines, so the line mentioned above (line 975) is not existing! Shall I post the content? It looks like normal C-code.

I also already deleted /root/.config/gedit/, but nothing changed.

Starting dconf-editor from a root terminal and examining the keys in dconf:/org/gnome/gedit did not show any suspicious (to me!) values. I can post some keys if you tell me how to dump them. I only know how to use the GUI tool.

What do I have to I do to restore my root-dconf settings for gedit (assuming this is the problem)? Or am I wrong and the problem has another cause?
Maybe you can even guess what messed it up so that I can avoid it in the future. Thanks!

Byte Commander
  • 107,489
  • The error is in line 33 of your ~/.gtkrc-2.0 file. What do you have there? – Rmano Apr 06 '15 at 15:05
  • @Rmano Thanks for pointing out. I had copied a paragraph from a website into that file not noticing that it used wrong "" characters. I replaced them and now this error is gone. I updated my question. But this was not the error causing gedit to fail launching as root. – Byte Commander Apr 06 '15 at 15:15
  • did you try just to completely reinstall gedit? – JoKeR Apr 06 '15 at 17:22
  • @JoKeR No. Can I backup the settings for my user profile and restore them later? (if yes: how?) Because I want to keep those settings which are working. – Byte Commander Apr 06 '15 at 17:27
  • you can backup anything it's a bit too long to explain about backup better read https://help.ubuntu.com/community/BackupYourSystem I'd recommend you simply to --reinstall gedit to see if it work it might. – JoKeR Apr 06 '15 at 17:32
  • also a good tutorial on backing up http://askubuntu.com/questions/9135/how-to-backup-settings-and-list-of-installed-packages – JoKeR Apr 06 '15 at 17:33
  • @JoKeR I was not asking on how to do a full backup in general, but which how I can copy only the gedit settings for one user profile to a backup location. I assume it is not a config file but dconf entries. So how could I back up (and later restore) a dconf key tree? – Byte Commander Apr 06 '15 at 17:46
  • it's not about full system backup please read the 2nd link closer it says personal data & settings e.g. rsync --progress /home/yourname/./config/.dconf and /path/to/user/profile/backup/here for more options list rsync --help – JoKeR Apr 06 '15 at 18:10
  • @JoKeR I did reinstall now, but nothing changed. Still the same errors. – Byte Commander Apr 06 '15 at 19:04
  • I might found a solution for you check this thread http://askubuntu.com/questions/323776/gsettings-not-working-over-ssh – JoKeR Apr 06 '15 at 19:12
  • @JoKeR No, sorry. Both answers did not work. Neither the "DISPLAY=:0 gedit" nor the "dbus-launch gedit". Display changes nothing, dbus-launch tells me it is not installed, but apt-get install dbus-x11 tells me it IS installed and up to date. I bet this has to do with XFCE. Could it be that dbus is running on Unity only (and Gnome maybe)? – Byte Commander Apr 06 '15 at 19:19
  • there are lots of bug reports even on Launchpad that similar to your issue I cannot tell exactly I use standard unity environment and I never experienced these kind of errors. Maybe try to reinstall the environment you're currently using to see if it do any change. – JoKeR Apr 06 '15 at 19:30
  • @JoKeR You mean sudo apt-get install xubuntu-desktop --reinstall? What will happen to my settings then? – Byte Commander Apr 06 '15 at 19:37
  • yes you can backup your settings as in my previous posts suggested though with --reinstall I don't think they will be removed but when you'll do --reinstall with purge before that might. But of course if it's got messed up in some way it's better off to purge it and reinstall. – JoKeR Apr 06 '15 at 19:42
  • I also see in one of your posts in your question it says cannot open display in my posted solution thread steeldriver's answer provide some similar issue I think, you can try fixes with that workaround. – JoKeR Apr 06 '15 at 19:50
  • @JoKeR The display error was only with pkexec. But this is not the problem, neither is dbus, as it works as normal user under XFCE without dbus too. It is that "(g-exec-error-quark, 8) that is the problem. – Byte Commander Apr 06 '15 at 19:53
  • @JoKeR I solved my problem and posted it as answer. Just if you are interested in what the problem was... – Byte Commander Apr 06 '15 at 23:38
  • glad for you I'll give it +1 :) – JoKeR Apr 07 '15 at 10:41

1 Answers1

4

I somehow managed to solve my problem and get gedit back to work, even for root.

What I did was

  1. sudo apt-get install --reinstall dbus dbus-x11

    to reinstall some dbus-packages which I probably messed up some time ago by running make uninstall on a package containing dbus parts.

  2. dconf dump /org/gnome/gedit/ > /home/bytecommander/dconf-gedit.dump followed by opening a root shell with sudo -i and as root:
    dconf load /org/gnome/gedit/ < /home/bytecommander/dconf-gedit.dump

    to copy the working dconf-settings for gedit from my normal user profile over to root's dconf database.

After that it works like a charm. Even the dconf-warnings about dbus-launch disappeared.

Byte Commander
  • 107,489
  • As far as I know sudo dconf doesn't act on the dconf database of the super-user. Instead it interacts with the current DBus session interface. You need to start a separate DBus session for the super-user and set the correct environment variables for HOME and DBUS_* for it to work. – David Foerster Apr 06 '15 at 23:41
  • @DavidFoerster Really? I don't know. I dumped to a file and loaded within a root shell (sudo -i). I just thought I could shorten the command. Is my real approach okay then? – Byte Commander Apr 06 '15 at 23:43
  • I don't know. Since sudo -i initiates a login shell with an entirely new set of environment variables, at least it wouldn't try to use the user DBus session, but I'm not sure, if it finds or starts the correct DBus session for the super-user. You can test it, by comparing the output of env | grep -e '^DBUS_' in both environments. Curiously, for me it's empty after sudo -i and sudo env | grep -e '^DBUS_'. I guess, that's because sudo filters some well-known session-related environment variables including DBUS_*. – David Foerster Apr 06 '15 at 23:45
  • @DavidFoerster I will edit it and change to my original steps then. I think it did change the values, because now I have the same colouring scheme as root like as normal user. It was different before. – Byte Commander Apr 06 '15 at 23:47
  • bytecommander@AlkaliMetal:~$ env | grep -e '^DBUS_' --> DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-zA0nZROAtK while root@AlkaliMetal:~# env | grep -e '^DBUS_' gives nothing. – Byte Commander Apr 06 '15 at 23:50
  • @ByteCommander, Just tried your answer.. doesn't work. – Pacerier Jun 27 '16 at 14:05
  • @Pacerier Well, then you probably have a different problem. You should ask a new question where you describe your issue in detail. A link to this question might help if there are many similarities. – Byte Commander Jun 27 '16 at 14:55