From 931fe5658610e8ba49015fd291aefcbe39f40975 Mon Sep 17 00:00:00 2001 From: Prakash Rudraraju Date: Thu, 19 Mar 2026 17:32:35 +0000 Subject: [PATCH] tsnet: fall back to 'tsnet' when os.Executable fails on darwin Updates #19050 When tsnet.Server.start() is called with both Hostname and Dir explicitly set, os.Executable() failure should not prevent the server from starting. Extend the existing ios fallback to also cover darwin, where the same failure occurs when the Go runtime is embedded in a framework launched via Xcode's debug launcher. Signed-off-by: Prakash Rudraraju --- tsnet/tsnet.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tsnet/tsnet.go b/tsnet/tsnet.go index 38ea86599..333af2fcf 100644 --- a/tsnet/tsnet.go +++ b/tsnet/tsnet.go @@ -618,10 +618,15 @@ func (s *Server) start() (reterr error) { // directory and hostname when they're not supplied. But we can fall // back to "tsnet" as well. exe = "tsnet" - case "ios": + case "ios", "darwin": // When compiled as a framework (via TailscaleKit in libtailscale), - // os.Executable() returns an error, so fall back to "tsnet" there - // too. + // os.Executable() returns an error on iOS. The same failure occurs + // on macOS (darwin) when the framework is loaded in a process + // launched by a debugger or certain host environments (e.g. Xcode), + // where the OS does not expose a resolvable executable path to the + // embedded Go runtime. Fall back to "tsnet" in both cases — the + // value is only used as a default hostname/directory when neither + // Server.Hostname nor Server.Dir is set. exe = "tsnet" default: return err