{"record":{"id":"d51cd2239648dcf5","repo":"lbjlaq/Antigravity-Manager","slug":"keyring-write-timed-out-10s-the-d-bus-session-bus-is-not","errorCode":null,"errorMessage":"Keyring write timed out (10s). The D-Bus session bus is not reachable from this process.","messagePattern":"Keyring write timed out \\(10s\\)\\. The D-Bus session bus is not reachable from this process\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/modules/integration.rs","lineNumber":393,"sourceCode":"\n            let child_pid = child.id();\n            let (tx, rx) = mpsc::channel::<Result<std::process::Output, std::io::Error>>();\n            std::thread::spawn(move || {\n                let _ = tx.send(child.wait_with_output());\n            });\n\n            let output = match rx.recv_timeout(std::time::Duration::from_secs(10)) {\n                Ok(result) => {\n                    result.map_err(|e| format!(\"Failed to wait for secret-tool: {}\", e))?\n                }\n                Err(_) => {\n                    let _ = Command::new(\"kill\")\n                        .args([\"-9\", &child_pid.to_string()])\n                        .output();\n                    crate::modules::logger::log_error(\n                        \"[Desktop] secret-tool store blocked for >10s — D-Bus session bus unreachable.\",\n                    );\n                    return Err(\n                        \"Keyring write timed out (10s). The D-Bus session bus is not reachable from this process.\"\n                            .to_string(),\n                    );\n                }\n            };\n\n            if !output.status.success() {\n                let err_msg = String::from_utf8_lossy(&output.stderr);\n                return Err(format!(\"Linux secret-tool failed: {}\", err_msg.trim()));\n            }\n\n            Ok(())\n        };\n\n        // 1. 优先尝试写入 'login' 集合（agy CLI 所需）\n        let login_res = store_to_collection(Some(\"login\"), payload_json.as_bytes());\n\n        // 2. 同时写入默认集合（保证其他依赖 default collection 的系统工具也能读取）","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/lbjlaq/Antigravity-Manager/blob/90a2b6b20797e2e593a83d0c54ab86037863fe70/src-tauri/src/modules/integration.rs#L375-L411","documentation":"write_to_system_keyring shells out to secret-tool (libsecret) to store a credential and enforces a 10-second timeout. If the child process hangs — typically because no D-Bus session bus is reachable — the function aborts and returns this error string instead of blocking forever.","triggerScenarios":"on_account_switch triggers a keyring write while the process has no D-Bus session bus (secret-tool blocks >10s), e.g. running the app via SSH, systemd service, cron, or a desktop session without gnome-keyring/secret-service.","commonSituations":"Launching the Tauri app from a headless session or sudo -E; SSH without dbus-launch; broken XDG_RUNTIME_DIR so the bus address is unresolvable.","solutions":["Ensure a D-Bus session bus is running and DBUS_SESSION_BUS_ADDRESS is set in the app's environment","Install/enable a secret service (gnome-keyring) and unlock the login keyring","Launch the app from a normal desktop session rather than SSH/systemd/cron","Fall back to file-based or in-app credential storage when the keyring is unavailable"],"exampleFix":"// before\nreturn Err(\"Keyring write timed out (10s). The D-Bus session bus is not reachable from this process.\".to_string());\n// after\nreturn Err(format!(\n    \"Keyring write timed out (10s). D-Bus session bus unreachable (DBUS_SESSION_BUS_ADDRESS={:?}). Install/unlock gnome-keyring or configure a fallback store.\",\n    std::env::var(\"DBUS_SESSION_BUS_ADDRESS\").as_deref().unwrap_or(\"<unset>\")\n));","handlingStrategy":"fallback","validationCode":"let bus_ok = std::env::var(\"DBUS_SESSION_BUS_ADDRESS\").map(|p| std::path::Path::new(&p).exists()).unwrap_or(false); if !bus_ok { return Err(\"keyring unavailable: no D-Bus session bus\".into()); }","typeGuard":null,"tryCatchPattern":"match write_to_system_keyring(entry, secret) { Err(e) if e.contains(\"timed out\") => { log::warn!(\"{e}; falling back to encrypted file store\"); fallback_store.write(entry, secret) } r => r }","preventionTips":["Detect secret-service availability at startup and warn early","Provide a documented fallback credential store","Avoid launching the app from environments without a session bus (SSH/cron/systemd)"],"tags":["keyring","dbus","linux","timeout"],"backgroundTag":"request-timeout","analyzedSha":"90a2b6b20797e2e593a83d0c54ab86037863fe70","analyzedAt":"2026-09-19T08:34:01.322Z","contentChangedAt":"2026-09-19T08:34:01.322Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}