Failed to connect to socket /opt/local/var/run/dbus/system_bus_socket: No such file or directory

Viewed 18257

I was trying to send message to the microbit using Bluezero I am using macOS, but got and error.

Sample code.

from bluezero import microbit
ubit = microbit.Microbit(adapter_addr='x',
                         device_addr='x',
                         accelerometer_service=True,
                         button_service=True,
                         magnetometer_service=False,
                         pin_service=False,
                         temperature_service=True)

my_text = 'Hello, world'
ubit.connect()

while my_text is not '':
    ubit.text = my_text
    my_text = input('Enter message: ')

ubit.disconnect()

Error

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /opt/local/var/run/dbus/system_bus_socket: No such file or directory

2 Answers

I've get this error on Ubuntu 20

Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

normally this file is created/listening by dbus daemon

# netstat --all --program | grep system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     19161    1/init               /run/dbus/system_bus_socket

but on this server dbus.service is not running

# systemctl status dbus.service
ā— dbus.service - D-Bus System Message Bus
 Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
 Active: inactive (dead)
 TriggeredBy: ā— dbus.socket
 Docs: man:dbus-daemon(1)

attempt to start dbus.service failed

# systemctl start dbus.service
Failed to start dbus.service: Operation refused, unit dbus.service may be requested by dependency only (it is configured to refuse manual start/stop).

Maybe it can be started by systemctl start dbus.socket but I've solved this by finding service which has dependency on dbus.service it was firewalld

# grep -r dbus /etc/systemd/system/*
/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service:After=dbus.service

and start it

# systemctl start firewalld

and that's it

# ls -la /var/run/dbus/system_bus_socket
srw-rw-rw- 1 root root 0 Jul 28 13:45 /var/run/dbus/system_bus_socket

The Bluezero library talks via DBus to the BlueZ bluetooth daemon (bluetoothd). As BlueZ is not available for MacOS, this is not going to work.

Related