{"record":{"id":"78f48d0726d30707","repo":"AdguardTeam/AdGuardHome","slug":"getting-executable-path-v","errorCode":null,"errorMessage":"getting executable path: %v","messagePattern":"getting executable path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghos/service_darwin.go","lineNumber":19,"sourceCode":"//go:build darwin\n\npackage aghos\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/AdguardTeam/golibs/log\"\n)\n\n// preCheckActionStart performs the service start action pre-check.  It warns\n// user that the service should be installed into Applications directory.\nfunc preCheckActionStart() (err error) {\n\texe, err := os.Executable()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting executable path: %v\", err)\n\t}\n\n\texe, err = filepath.EvalSymlinks(exe)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"evaluating executable symlinks: %v\", err)\n\t}\n\n\tif !strings.HasPrefix(exe, \"/Applications/\") {\n\t\tlog.Info(\"warning: service must be started from within the /Applications directory\")\n\t}\n\n\treturn err\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghos/service_darwin.go#L1-L33","documentation":"In the macOS-only pre-flight check before starting the service, os.Executable failed, so the running binary's own path could not be determined. The %v (not %w) wrap means the underlying error is only visible in text, not unwrappable.","triggerScenarios":"Calling the service start action on macOS when os.Executable returns an error — the binary was deleted or replaced while running (proc path gone), /proc/self/exe-equivalent read failure, or unusual launch environments that break executable resolution.","commonSituations":"Replacing an AdGuardHome binary in place and restarting from a half-deleted state; launching via symlinks through deleted paths; sandboxed launchers blocking executable introspection.","solutions":["Reinstall/re-copy the binary to /Applications so its executable path is resolvable, then start again","Avoid deleting or overwriting the running binary; stop the service before upgrades","Relaunch from a stable absolute path rather than a transient one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Executable(); err != nil { /* refuse to start; binary path unresolvable */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never delete or overwrite a running binary; stop the service first during upgrades","Install the app in a stable location like /Applications","Keep launcher paths stable and absolute"],"tags":["macos","os-executable","service-start","darwin"],"backgroundTag":"os-executable-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}