Client failed to connect to the D-BUS daemon. Failed to connect to socket /tmp/dbus-<something>: Connection refused

huangapple go评论59阅读模式
英文:

Client failed to connect to the D-BUS daemon. Failed to connect to socket /tmp/dbus-<something>: Connection refused

问题

我经常看到标题中列出的错误。

我使用Linux Mint,准确地说是几个不同版本(18.3和21.1)。

我在虚拟机上(在Hyper-V下,如果有关系的话)从命令行运行应用程序,并从另一台机器上的X服务器(瘦客户机)实际驱动它们。我启动虚拟机,它启动了X窗口系统,然后使用sudo来关闭lightdm(这样可以关闭X窗口以节省资源)。然后我以文本模式登录,并从命令行运行xterm,将显示变量指向我的瘦客户机。这样我就在瘦客户机上得到了一个xterm窗口,从中我可以在虚拟机上运行应用程序并在瘦客户机上与它们交互。

但我经常收到那个错误消息。整天都是这样。不管是gvim、firefox、chromium还是其他什么应用程序,都会发生这种情况。

如果我在虚拟机中运行X窗口系统,并从那里的命令行运行应用程序,我就不会遇到这个错误。只有当我以文本模式运行虚拟机并在瘦客户机上使用X窗口系统时才会发生这种情况。

这些应用程序仍然可以工作。它们的行为(大多数时候)是正常的。但每次我都会收到那个错误消息。

当运行gvim时,我总是收到那个消息,还会弹出一个额外的窗口,上面写着:“在加载或保存gvim的配置信息时发生错误。您的某些配置设置可能无法正常工作。” 我没有注意到gvim的行为有任何异常。但是一直不得不关闭那个弹出窗口真的很烦人。我一天之中会多次使用gvim。我每次都会收到错误消息和弹出窗口。

此外,以这种方式启动chromium时,它无法记住我的任何用户名和密码(这不是完全正常的操作)。

我已经查看了所有关于这个错误消息的其他条目。我尝试了各种方法,但没有一个能解决我的问题。

是的,dbusdbus-x11 都已安装。

运行 dbus-launch 给了我一些状态信息,但没有效果。

如果我运行 service dbus status,它告诉我它是活动的。运行 service dbus start 会要求我输入密码(就像我在使用sudo时一样)来启动“dbus.socket”和“dbus.service”,但之后我仍然会收到错误消息,所以这些似乎没有起到任何作用。

虽然我使用sudo来关闭lightdm,但对于其他任何事情我都不使用sudo。我在虚拟机中有一个用户帐户,我使用它登录(以文本模式),启动xterm并运行所有的应用程序。所以这不应该是一个权限问题。

有什么其他建议吗?这主要是一个烦恼,但我想让我的配置达到一个完全没有这个问题的地步。

英文:

I'm seeing the error, as listed in the title, quite often.

I'm using Linux Mint, a couple different versions (18.3 and 21.1 to be precise).

I'm running applications, from the command-line, on a VM (under Hyper-V, if it matters) and actually driving them from an X-server on a different machine (thin client). I start the VM, which starts X-Windows, then use sudo to kill lightdm (which kills X-Windows to save resources). Then I login, in text mode, and run xterm from the command-line, pointing the display variable to my thin client. This gives me an xterm window on my thin client, from which I can run the apps on the VM and interact with them on the thin client.

But I routinely get that error message. All day long. This happens with gvim, firefox, chromium, you name it.

If I run X-Windows in the VM and run the applications from the command-line there, I do NOT get this error. It ONLY happens when I'm running the VM in text mode and using X-Windows on a thin client.

The apps still work. They behave (mostly) normally. But I get that error message every time.

When running gvim, I always get that message and I get an additional pop-up saying that "An error occurred while loading or saving configuration information for gvim. Some of your configuration settings may not work properly." I'm not noticing anything out of the ordinary with gvim's behavior. But having to kill that pop-up all the time is a pain. I use gvim dozens of time on any given day. I get the error and the pop-up every time.

Additionally, when I start chromium in this fashion, it fails to remember any of my usernames and passwords (not ENTIRELY normal operation).

I've been looking at all the other entries for this error message. I've tried various things but none of them are clearing the problem for me.

Yes, dbus and dbus-x11 are installed.

Running dbus-launch gives me some status info but has no effect.

If I run service dbus status, it tells me that it is active. Running service dbus start asks for passwords (as if I were doing something under a sudo) to start "dbus.socket" and "dbus.service" but I still get the errors afterwards, so those don't appear to be accomplishing anything.

While I use sudo to kill lightdm, I do NOT use sudo for anything else. I have a user account in the VM, with which I login (in text mode), start xterm and run all the apps. So this should NOT be a perms issue.

Suggestions on what else to try? This is, mostly, an annoyance but I'd like to get my config to a point where this isn't an issue at all.

答案1

得分: 1

使用dbus-launch来运行您的xterm作为dbus的子进程:

dbus-launch [--exit-with-session] xterm &
dbus-run-session xterm &

或者,如果Mint与Debian类似的话,安装dbus-user-session包,这将导致始终在所有登录类型(包括文本控制台和SSH登录)的固定位置启动会话总线。"user"总线将通过"用户服务"来控制:

systemctl --user status dbus

(注意:由于"用户"总线在切换$DISPLAY后仍然独立存在,因此您需要运行以下命令将环境重新导入到正在运行的dbus-daemonsystemd --user进程中:

dbus-update-activation-environment --systemd DISPLAY

要使效果生效,您可能没有注意到的是,dbus-launch会在后台启动一个dbus-daemon实例;"status info"是您的应用程序应连接到的总线的地址。输出旨在进行eval,以便新的DBUS_SESSION_BUS_ADDRESS会替换您环境中的旧地址(或在~/.dbus缓存的"autolaunch"数据中的地址)。

ssh-agent非常类似,如果您未指定要运行的"child"命令,使用方式如下:

eval "$(dbus-launch)"

这种用法通常会导致残留的dbus-daemon进程,除非添加--exit-with-x11--exit-with-session选项。

如果在虚拟机中运行X-Windows并从命令行运行应用程序,则不会出现此错误,这是因为在登录期间图形会话已经运行了dbus-launch(可能作为dbus-x11脚本的一部分),并将正确的DBUS_SESSION_BUS_ADDRESS放入了环境中。关闭X服务器会导致dbus-launch终止dbus-daemon,因此地址不再有任何监听。

如果运行service dbus status,它会告诉您它处于活动状态,但那是错误的总线。dbus.service代表全局的"system"总线;您的错误消息正在寻找每个用户的"session"总线。

英文:

Run your xterm as a child of dbus-launch:

dbus-launch [--exit-with-session] xterm &amp;         (older)
dbus-run-session xterm &amp;                          (newer)

Alternatively:

If Mint is anything like Debian &ndash; install the dbus-user-session package, which will cause a session bus to always be started at a fixed location for all login types (including text console and SSH logins). The "user" bus would be controlled through a "user service":

systemctl --user status dbus

(Note &ndash; since the "user" bus continues to exist independently of the X display, after switching $DISPLAY you would need to run:

dbus-update-activation-environment --systemd DISPLAY

to re-import environment to the running dbus-daemon and systemd --user processes.)

> Running dbus-launch gives me some status info but has no effect.

Its effect that you haven't noticed is that dbus-launch starts a dbus-daemon instance in background; the "status info" is the address of the new bus that your apps are supposed to connect to. The output is meant to be eval'd, so that the new DBUS_SESSION_BUS_ADDRESS would replace the stale one that's currently in your environment (or in the ~/.dbus cached "autolaunch" data).

Very similar to ssh-agent, if you do not specify a "child" command to run, the usage would be:

eval &quot;$(dbus-launch)&quot;

This usage tends to leave stale dbus-daemon processes lingering around, unless --exit-with-x11 or --exit-with-session is added.

> If I run X-Windows in the VM and run the applications from the command-line there, I do NOT get this error

You do not get this error because the graphical session has run dbus-launch during login (likely as part of the dbus-x11 scripts) and has put the correct DBUS_SESSION_BUS_ADDRESS in the environment. Killing the X server causes dbus-launch to kill the dbus-daemon, so the address no longer has anything listening.

> If I run service dbus status, it tells me that it is active.

That's the wrong bus. dbus.service represents the global "system" bus; your error messages are looking for the per-user "session" bus.

huangapple
  • 本文由 发表于 2023年7月14日 01:23:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定