kovidgoyal/kitty · error

failed to register dbus name: %v

Error message

failed to register dbus name: %v

What it means

Portal.Start wraps the error returned by bus.RequestName for PORTAL_BUS_NAME when the request itself errors (not merely queued). This indicates a transport-level failure talking to the bus daemon.

Source

Thrown at kittens/desktop_ui/portal.go:189

		introspect.IntrospectData, interface_data,
	}
	if len(properties) > 0 {
		interfaces = append(interfaces, prop.IntrospectData)
	}
	n := &introspect.Node{Name: object_path, Interfaces: interfaces}
	if err = conn.Export(introspect.NewIntrospectable(n), op, introspect.IntrospectData.Name); err != nil {
		return fmt.Errorf("failed to export introspected methods with error: %w", err)
	}
	return
}

func (self *Portal) Start() (err error) {
	if self.bus, err = dbus.SessionBus(); err != nil {
		return fmt.Errorf("could not connect to session D-Bus: %s", err)
	}
	reply, err := self.bus.RequestName(PORTAL_BUS_NAME, dbus.NameFlagDoNotQueue)
	if err != nil {
		return fmt.Errorf("failed to register dbus name: %v", err)
	}
	if reply != dbus.RequestNameReplyPrimaryOwner {
		return fmt.Errorf("can't register D-Bus name: name already taken")
	}
	props := PropSpec{
		"version": {Value: uint32(1), Writable: false, Emit: prop.EmitFalse},
	}
	signals := SignalSpec{
		"SettingChanged": {{"namespace", "s"}, {"key", "s"}, {"value", "v"}},
	}
	methods := MethodSpec{
		"Read":    {{"namespace", "s", false}, {"key", "s", false}, {"value", "v", true}},
		"ReadAll": {{"namespaces", "as", false}, {"value", "a{sa{sv}}", true}},
	}
	if err = ExportInterface(self.bus, self, SETTINGS_INTERFACE, DESKTOP_OBJECT_PATH, methods, props, signals); err != nil {
		return
	}
	methods = MethodSpec{

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Check the wrapped %v error for the transport cause
  2. Restart the session bus daemon (systemctl --user restart dbus) and retry
  3. Confirm no firewall/permission issues on abstract sockets in containers
Defensive patterns

Strategy: retry

Try / catch

var err error
for i := 0; i < 3; i++ {
    if err = portal.Start(); err == nil || !strings.Contains(err.Error(), "failed to register dbus name") {
        break
    }
    time.Sleep(200 * time.Millisecond)
}

Prevention

When it happens

Trigger: RequestName fails because the connection was closed after SessionBus() succeeded, or the bus daemon rejected the call.

Common situations: Bus daemon crashed or restarted between connect and name request; flaky socket transport; the process was signaled mid-startup.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/966d2602cdb985a5. Report an issue: GitHub.