{"record":{"id":"1760d15b2161042a","repo":"kovidgoyal/kitty","slug":"failed-to-connect-to-system-bus-with-error-w","errorCode":null,"errorMessage":"failed to connect to system bus with error: %w","messagePattern":"failed to connect to system bus with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/desktop_ui/portal.go","lineNumber":277,"sourceCode":"\nfunc fetch_settings(conn *dbus.Conn, namespaces ...string) (ans ReadAllType, err error) {\n\tpath := \"/\" + strings.ToLower(strings.ReplaceAll(DESKTOP_PORTAL_NAME, \".\", \"/\"))\n\tobj := conn.Object(DESKTOP_PORTAL_NAME, dbus.ObjectPath(path))\n\tinterface_name := strings.ReplaceAll(DESKTOP_PORTAL_NAME, \"Desktop\", \"Settings\")\n\tif len(namespaces) == 0 {\n\t\tnamespaces = append(namespaces, \"\")\n\t}\n\tcall := obj.Call(interface_name+\".ReadAll\", dbus.FlagNoAutoStart, namespaces)\n\tif err = call.Store(&ans); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to read response from ReadAll with error: %w\", err)\n\t}\n\treturn\n}\n\nfunc show_settings(opts *ShowSettingsOptions) (err error) {\n\tconn, err := dbus.SessionBus()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to connect to system bus with error: %w\", err)\n\t}\n\tdefer conn.Close()\n\tvar response ReadAllType\n\tresponse, err = fetch_settings(conn, opts.InNamespace...)\n\tif opts.AsJson {\n\t\tunwrapped := make(map[string]map[string]any, len(response))\n\t\tfor ns, m := range response {\n\t\t\tw := make(map[string]any, len(m))\n\t\t\tfor k, a := range m {\n\t\t\t\tw[k] = a.Value()\n\t\t\t}\n\t\t\tunwrapped[ns] = w\n\t\t}\n\t\tj, err := json.MarshalIndent(unwrapped, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to format the response as JSON: %w\", err)\n\t\t}\n\t\tfmt.Println(string(j))","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/desktop_ui/portal.go#L259-L295","documentation":"show_settings calls dbus.SessionBus() and wraps its failure. Despite the message text saying 'system bus', the code actually connects to the session bus — the message is slightly misleading; the cause is a session bus connection failure.","triggerScenarios":"Running `kitten desktop-ui show-settings` in an environment where the D-Bus session bus is unavailable or DBUS_SESSION_BUS_ADDRESS is unset/invalid.","commonSituations":"SSH sessions, containers, cron jobs, or minimal environments without a running session bus.","solutions":["Set/verify DBUS_SESSION_BUS_ADDRESS and confirm the socket exists","Start a session bus with dbus-run-session or dbus-launch for non-graphical use","Share the host session bus socket into containers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if os.Getenv(\"DBUS_SESSION_BUS_ADDRESS\") == \"\" {\n    return errors.New(\"run inside a graphical session or set DBUS_SESSION_BUS_ADDRESS\")\n}","typeGuard":null,"tryCatchPattern":"conn, err := dbus.SessionBus()\nif err != nil {\n    // skip settings features; environment has no session bus\n}","preventionTips":["Run the kitten inside a real graphical session","Forward/share the session bus in SSH and container setups"],"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"}