{"record":{"id":"2b7a6f38787e8ea7","repo":"kovidgoyal/kitty","slug":"could-not-connect-to-session-d-bus-s","errorCode":null,"errorMessage":"could not connect to session D-Bus: %s","messagePattern":"could not connect to session D-Bus: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/desktop_ui/portal.go","lineNumber":185,"sourceCode":"\t\tProperties: properties,\n\t\tSignals:    signals,\n\t}\n\tinterfaces := []introspect.Interface{\n\t\tintrospect.IntrospectData, interface_data,\n\t}\n\tif len(properties) > 0 {\n\t\tinterfaces = append(interfaces, prop.IntrospectData)\n\t}\n\tn := &introspect.Node{Name: object_path, Interfaces: interfaces}\n\tif err = conn.Export(introspect.NewIntrospectable(n), op, introspect.IntrospectData.Name); err != nil {\n\t\treturn fmt.Errorf(\"failed to export introspected methods with error: %w\", err)\n\t}\n\treturn\n}\n\nfunc (self *Portal) Start() (err error) {\n\tif self.bus, err = dbus.SessionBus(); err != nil {\n\t\treturn fmt.Errorf(\"could not connect to session D-Bus: %s\", err)\n\t}\n\treply, err := self.bus.RequestName(PORTAL_BUS_NAME, dbus.NameFlagDoNotQueue)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to register dbus name: %v\", err)\n\t}\n\tif reply != dbus.RequestNameReplyPrimaryOwner {\n\t\treturn fmt.Errorf(\"can't register D-Bus name: name already taken\")\n\t}\n\tprops := PropSpec{\n\t\t\"version\": {Value: uint32(1), Writable: false, Emit: prop.EmitFalse},\n\t}\n\tsignals := SignalSpec{\n\t\t\"SettingChanged\": {{\"namespace\", \"s\"}, {\"key\", \"s\"}, {\"value\", \"v\"}},\n\t}\n\tmethods := MethodSpec{\n\t\t\"Read\":    {{\"namespace\", \"s\", false}, {\"key\", \"s\", false}, {\"value\", \"v\", true}},\n\t\t\"ReadAll\": {{\"namespaces\", \"as\", false}, {\"value\", \"a{sa{sv}}\", true}},\n\t}","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/desktop_ui/portal.go#L167-L203","documentation":"Portal.Start fails when dbus.SessionBus() cannot connect to the user's session bus (DBUS_SESSION_BUS_ADDRESS). The message wraps the underlying connection error.","triggerScenarios":"Running the desktop-ui kitten server in an environment without a session bus: SSH sessions without bus address forwarding, containers, cron jobs, or minimal Wayland/X setups.","commonSituations":"Missing or invalid DBUS_SESSION_BUS_ADDRESS env var; running inside a container or non-graphical session; ssh -X without dbus forwarding.","solutions":["Verify DBUS_SESSION_BUS_ADDRESS is set (echo $DBUS_SESSION_BUS_ADDRESS) and points to a live socket","Launch a session bus (dbus-launch, eval $(dbus-launch)) or use dbus-run-session","In containers/SSH, forward or share the host session bus socket","Use dbus-monitor or busctl --user to confirm the bus responds"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if os.Getenv(\"DBUS_SESSION_BUS_ADDRESS\") == \"\" {\n    return errors.New(\"no session bus; set DBUS_SESSION_BUS_ADDRESS\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := dbus.SessionBus(); err != nil {\n    // degrade gracefully: disable desktop-ui features\n}","preventionTips":["Probe for a session bus before launching the kitten server","Use dbus-run-session in headless test environments"],"tags":["dbus","desktop-ui","kitty","environment","connection"],"backgroundTag":"dbus-session-bus-unavailable","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}