项目场景:

对于systemd系统来说,DBUS是必不可少的工具,它是进程间通讯的桥梁。

问题描述

当我们在WSL2中安装QQ音乐的时候,打开崩溃,具体的提示错误是:Failed to connect to the bus: Failed to connect to socket /run/user/1000/bus: No such file or directory

意思就是没有/run/user/1000/bus这个文件,我们去这个目录下面确实没找到这个文件。

ls /run/user/1000/

dbus-1 gnupg pk-debconf-socket pulse snapd-session-agent.socket systemd wayland-0 wayland-0.lock

简单解释下: 1000是除了root用户外你创建的第一个用户ID,第二个ID是1001。

有些软件可能能够运行,但是像QQ音乐Linux版,没有这个文件就直接崩溃或不出声音。

原因分析:

DBUS简单理解就是用于处理进程间通讯的桥梁,用来在不同的Applications中相互传递消息。它的效率很高,很多发行版中都集成了。

有些Applications依赖这个东西,如果没有的话就不能正常运行。废话不多说,由于DBUS很复杂,有兴趣的可以自行搜索学习下。这里,我只说解决方法。

解决方案:

其实是缺少了一个包,我们搜索dbus看下就明白了。

dpkg -l | grep dbus

ii at-spi2-core 2.44.0-3 amd64 Assistive Technology Service Provider Interface (dbus core)

ii dbus 1.12.20-2ubuntu4.1 amd64 simple interprocess messaging system (daemon and utilities)

ii dbus-x11 1.12.20-2ubuntu4.1 amd64 simple interprocess messaging system (X11 deps)

ii libdbus-1-3:amd64 1.12.20-2ubuntu4.1 amd64 simple interprocess messaging system (library)

ii libdbusmenu-glib4:amd64 16.04.1+18.10.20180917-0ubuntu8 amd64 library for passing menus over DBus

ii libdbusmenu-gtk3-4:amd64 16.04.1+18.10.20180917-0ubuntu8 amd64 library for passing menus over DBus - GTK+ version

ii libnet-dbus-perl 1.2.0-1build3 amd64 Perl extension for the DBus bindings

ii python3-dbus 1.2.18-3build1 amd64 simple interprocess messaging system (Python 3 interface)

这里少了一个包dbus-user-session,装上这个包就不会报错了。

sudo apt install dbus-user-session

我们看下这个包的描述信息,重点看Description:

apt info dbus-user-session

Package: dbus-user-session

Version: 1.12.20-2ubuntu4.1

Priority: optional

Section: admin

Source: dbus

Origin: Ubuntu

Maintainer: Ubuntu Developers

Original-Maintainer: Utopia Maintenance Team

Bugs: https://bugs.launchpad.net/ubuntu/+filebug

Installed-Size: 133 kB

Provides: dbus-session-bus, default-dbus-session-bus

Depends: dbus (>= 1.12.20-2ubuntu4.1), libpam-systemd, systemd

Recommends: systemd-sysv

Breaks: dbus-x11 (<< 1.9.10-2~), policykit-1 (<< 0.105-12~), udisks2 (<< 2.1.5-2~)

Homepage: https://dbus.freedesktop.org/

Task: server-minimal, print-server, ubuntu-desktop-minimal, ubuntu-desktop, cloud-image, ubuntu-desktop-raspi, ubuntu-desktop-raspi, server, ubuntu-server-raspi, ubuntu-server-raspi, kubuntu-desktop, xubuntu-core, xubuntu-desktop, lubuntu-desktop, ubuntustudio-desktop-core, ubuntustudio-desktop, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop, ubuntu-budgie-desktop, ubuntu-budgie-desktop-raspi, ubuntu-budgie-desktop-raspi

Download-Size: 9442 B

APT-Manual-Installed: yes

APT-Sources: http://mirrors.aliyun.com/ubuntu jammy-security/main amd64 Packages

Description: simple interprocess messaging system (systemd --user integration)

D-Bus is a message bus, used for sending messages between applications.

Conceptually, it fits somewhere in between raw sockets and CORBA in

terms of complexity.

.

On systemd systems, this package opts in to the session model in which

a user's session starts the first time they log in, and does not end

until all their login sessions have ended. This model merges all

parallel non-graphical login sessions (text mode, ssh, cron, etc.), and up

to one graphical session, into a single "user-session" or "super-session"

within which all background D-Bus services are shared.

.

Multiple graphical sessions per user are not currently supported in this

mode; as a result, it is particularly suitable for gdm, which responds to

requests to open a parallel graphical session by switching to the existing

graphical session and unlocking it.

.

To retain dbus' traditional session semantics, in which login sessions

are artificially isolated from each other, remove this package and install

dbus-x11 instead.

.

See the dbus package description for more information about D-Bus in general.

N: There is 1 additional record. Please use the '-a' switch to see it

简单解释下: 意思就是这个东西是用来进程间通信的消息库,这个是依赖systemd系统的,在用户第一次登录进来开始一个会话,直到所有的登录会话都结束它才结束。

总结:

对于必须依赖这个包的程序有用,能正常运行的可以不装。

推荐阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: