Fix GConf Exception Failed to contact configuration server with dbus-launch
If you try to run an application as root or another user and see this error, you’ll quickly find that your saved state fails to load and your application spits out the error at least once if you run it on the command line. You can usually work around the “problem” by using the other user’s session variables by using sudo or calling su with a minus sign to inherit their environment.
Conf Exception caught: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-5FcF7XIfAN: Connection refused)
I've seen this problem in Ubuntu and Fedora. But I'm sure it's been a problem at some time or another for anyone running Gnome.
Permissions on ~/.dbus
The easiest fix, one which works 90% of the time is to fix the permissions on, or delete, the .dbus directory from your home directory. If you ran something as root and it took control of the session file in your .dbus directory, this will immediately fix the problem. If that didn't work, check the DBUS_SESSION_BUS environment variable and make sure you're not still seeing your old path which will point to the user you're logged into the desktop as. This is normal behavior when you don't use the minus sign on su, because you're _supposed_ to keep your environment when you do it this way. Normal behavior - will not fix!
But of course... Sometimes nothing seems to work, and you still need a fix. dbus-launch fixed this problem for me.
Run the offending application with dbus-launch which forces a new dbus session bus to spawn for this application. Don't skip the option or you'll end up with multiple dbus sessions left running in no time.
1 $ dbus-launch --exit-with-session ./my-app
This also happens when you're not running X but you want to spawn a dbus session and it's complaining it can't connect to an X server.
12345678910 [rootninja@defcon1 ~] pythonPython 2.6.2 (r262:71600, Jun 4 2010, 18:28:58)[GCC 4.4.3 20100127 (Red Hat 4.4.3-4)] on defcon4Type "help", "copyright", "credits", or "license" for more information.>>> import dbus>>> s = dbus.SessionBus()Traceback (most recent call last):File "/usr/lib/python2.6/site-packages/dbus/_dbus.py", line 219...dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed:dbus-launch failed to autolaunch D-Bus session: Autolaunch error: X11 initialization failed.
Use dbus-launch to spawn a session for all your pythonista needs.
1234567 [rootninja@defcon1 ~] dbus-launch --exit-with-session pythonPython 2.6.2 (r262:71600, Jun 4 2010, 18:28:58)[GCC 4.4.3 20100127 (Red Hat 4.4.3-4)] on defcon4Type "help", "copyright", "credits", or "license" for more information.>>> import dbus>>> s = dbus.SessionBus()>>>