{"record":{"id":"888e6340b7fcb4a5","repo":"kovidgoyal/kitty","slug":"can-t-register-d-bus-name-name-already-taken","errorCode":null,"errorMessage":"can't register D-Bus name: name already taken","messagePattern":"can't register D-Bus name: name already taken","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/desktop_ui/portal.go","lineNumber":192,"sourceCode":"\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}\n\tif err = ExportInterface(self.bus, self, SETTINGS_INTERFACE, DESKTOP_OBJECT_PATH, methods, props, signals); err != nil {\n\t\treturn\n\t}\n\tmethods = MethodSpec{\n\t\t\"OpenFile\": {{\"handle\", \"o\", false}, {\"app_id\", \"s\", false}, {\"parent_window\", \"s\", false}, {\"title\", \"s\", false}, {\"options\", \"a{sv}\", false},\n\t\t\t{\"response\", \"u\", true}, {\"results\", \"a{sv}\", false},\n\t\t},","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/desktop_ui/portal.go#L174-L210","documentation":"RequestName with NameFlagDoNotQueue returned a reply other than PrimaryOwner, meaning another process already owns PORTAL_BUS_NAME (org.freedesktop.impl.portal.desktop.kitty or similar) and the name cannot be acquired.","triggerScenarios":"Starting the desktop-ui kitten portal while another instance (or another kitty portal backend) is already running and owns the bus name.","commonSituations":"Two kitty sessions both launching the desktop-ui kitten; a stale portal process from a crashed session; another desktop portal backend registered under the same name.","solutions":["Find and stop the existing owner: busctl --user --list | grep portal or dbus-send to inspect, then kill the stale process","Enable the portal only once per session (kitten desktop-ui enable) instead of per-window","Log out/in or restart the session if a zombie process holds the name"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := portal.Start(); err != nil {\n    if strings.Contains(err.Error(), \"name already taken\") {\n        // another instance is running; exit quietly\n        return nil\n    }\n}","preventionTips":["Enable the portal once per session, not per window","Detect and exit silently when the name is already owned by another kitty instance"],"tags":["dbus","desktop-ui","kitty","single-instance"],"backgroundTag":"dbus-name-already-owned","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}