{"record":{"id":"1609a8ee80be0217","repo":"vercel/turborepo","slug":"daemon-socket-path-is-owned-by-another-user-path","errorCode":null,"errorMessage":"daemon socket path is owned by another user: {path}","messagePattern":"daemon socket path is owned by another user: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/turborepo-daemon/src/endpoint.rs","lineNumber":241,"sourceCode":"                ConvertSidToStringSidW, ConvertStringSecurityDescriptorToSecurityDescriptorW,\n                GetNamedSecurityInfoW, SetNamedSecurityInfoW, SDDL_REVISION_1, SE_FILE_OBJECT,\n            },\n            EqualSid, GetSecurityDescriptorDacl, GetTokenInformation, TokenUser, ACL,\n            DACL_SECURITY_INFORMATION, OWNER_SECURITY_INFORMATION,\n            PROTECTED_DACL_SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, PSID, TOKEN_QUERY,\n            TOKEN_USER,\n        },\n        System::Threading::{GetCurrentProcess, OpenProcessToken},\n    };\n\n    pub fn ensure_current_user_owns_path(path: &AbsoluteSystemPath) -> Result<(), std::io::Error> {\n        let current_user = current_user_sid()?;\n        let owner = path_owner_sid(path)?;\n\n        if unsafe { EqualSid(current_user.as_ptr(), owner.as_ptr()) } != 0 {\n            Ok(())\n        } else {\n            Err(std::io::Error::new(\n                std::io::ErrorKind::PermissionDenied,\n                format!(\"daemon socket path is owned by another user: {path}\"),\n            ))\n        }\n    }\n\n    pub fn set_owner_only_dacl(\n        path: &AbsoluteSystemPath,\n        inherit_to_children: bool,\n    ) -> Result<(), std::io::Error> {\n        let current_user = current_user_sid()?;\n        let current_user = sid_to_string(current_user.as_ptr())?;\n        let inherit_flags = if inherit_to_children { \"OICI\" } else { \"\" };\n        let sddl = format!(\"D:P(A;{inherit_flags};FA;;;{current_user})\");\n        let sddl = wide_null(OsStr::new(&sddl));\n\n        let mut descriptor = ptr::null_mut();\n        if unsafe {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-daemon/src/endpoint.rs#L223-L259","documentation":"During Windows daemon startup, ensure_current_user_owns_path (endpoint.rs:241) reads the path's owner SID with GetNamedSecurityInfoW and compares it to the current user's SID with EqualSid. A mismatch produces this PermissionDenied error: the directory that will host the daemon socket belongs to a different account, so turbo refuses to run there to stop another user from controlling the pipe directory.","triggerScenarios":"Daemon start where the socket dir (typically under %TEMP% or the user profile) was created by a different Windows account — admin provisioning, `runas`/service-account runs, or a profile restored from another machine.","commonSituations":"Machine shared between accounts and turbo daemon dirs created by the first one Running the daemon as a service/scheduled task under SYSTEM after using it interactively Profile migration/cloning keeping old ownership","solutions":["Delete the stale daemon directory shown in the message (usually under %TEMP%\\turborepo or the user profile) so the current user recreates it","Take ownership of the existing directory: `takeown /f <path> /r` then `icacls <path> /setowner <you>`","Always run turbo/daemon as the same Windows account that owns those dirs"],"exampleFix":":: stop daemon, remove stale dir, restart\nturbo daemon stop\nrmdir /s /q \"%TEMP%\\turborepo\"\nturbo daemon start","handlingStrategy":"fallback","validationCode":"// Windows: check ownership before starting the daemon\nfn owned_by_me(path: &Path) -> bool {\n    // use windows_acl or icacls exit code in a pre-step\n    std::process::Command::new(\"icacls\").arg(path).status().map(|s| s.success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"// on PermissionDenied 'owned by another user': drop the dir and retry once\nmatch start_daemon() {\n    Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied && e.to_string().contains(\"owned by another user\") => {\n        std::fs::remove_dir_all(daemon_dir).ok();\n        start_daemon()?; // retry once after recreation\n    }\n    r => r,\n}","preventionTips":["Run turbo and its daemon under one Windows account","After runas/service experiments, clear the daemon dir under %TEMP%"],"tags":["daemon","windows","security","permissions","ownership","sid"],"backgroundTag":"file-ownership-mismatch","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}