{"record":{"id":"c4bf893c4683f634","repo":"cloudflare/cloudflared","slug":"error-determining-executable-path-v","errorCode":null,"errorMessage":"error determining executable path: %v","messagePattern":"error determining executable path: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/linux_service.go","lineNumber":259,"sourceCode":"\tContent: `# Configuration for the cloudflared OpenRC service.\n\n# User the cloudflared daemon runs as. Defaults to root.\n#cloudflared_user=\"cloudflared\"\n`,\n}\n\nvar noUpdateServiceFlag = &cli.BoolFlag{\n\tName:  \"no-update-service\",\n\tUsage: \"Disable auto-update of the cloudflared linux service, which restarts the server to upgrade for new versions.\",\n\tValue: false,\n}\n\nfunc installLinuxService(c *cli.Context) error {\n\tlog := logger.CreateLoggerFromContext(c, logger.EnableTerminalLog)\n\n\tetPath, err := os.Executable()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error determining executable path: %v\", err)\n\t}\n\ttemplateArgs := ServiceTemplateArgs{\n\t\tPath: etPath,\n\t}\n\n\tvar extraArgs []string\n\tif c.NArg() == 0 {\n\t\t// If passed no arguments e.g., \"$ cloudflared service install\",\n\t\t// install the service using the detected config file (or error-out if\n\t\t// no config exists).\n\t\tif extraArgs, err = buildArgsForConfig(c, log); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// If passed one argument e.g., \"$ cloudflared service install <token>\"\n\t\t// write the token to the config directory and install the service\n\t\t// using --token-file pointing to that file. This is the quick setup\n\t\t// the tunnel UI suggests.","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/linux_service.go#L241-L277","documentation":"During `cloudflared service install` on Linux, installLinuxService calls os.Executable() to embed the current binary's path into the generated systemd/SysV unit file. If the kernel or runtime cannot resolve the executable path, the install aborts with this error carrying the OS reason (%v).","triggerScenarios":"os.Executable() fails — typically because the binary was deleted or replaced after start (Linux returns ENOENT from /proc/self/exe), the binary was built/linked in an unusual way, or /proc is not mounted (containers without procfs).","commonSituations":"Installing the service from a binary in a temp directory that was removed; running `cloudflared service install` inside a chroot/container with an incomplete /proc; deleting and rebuilding the binary while the CLI process was starting up.","solutions":["Check the binary still exists at the path you invoked: `which cloudflared` and `ls -l $(which cloudflared)`; reinstall if deleted.","Ensure /proc is mounted (mount -t proc proc /proc) when inside a container or chroot.","Copy the binary to a stable location (e.g. /usr/local/bin/cloudflared) and run service install from there, not from /tmp.","Retry after restoring the binary — os.Executable() reads /proc/self/exe, so a live valid binary resolves the path."],"exampleFix":"// before: binary removed from tmp before install\n/tmp/cloudflared service install\n// after: stable install location\nsudo cp /tmp/cloudflared /usr/local/bin/cloudflared && sudo /usr/local/bin/cloudflared service install","handlingStrategy":"validation","validationCode":"// preflight: binary exists and /proc readable (Linux)\nfunc canResolveExecutable() error {\n\tif _, err := os.Stat(\"/proc/self/exe\"); err != nil {\n\t\treturn fmt.Errorf(\"/proc/self/exe unavailable: %w\", err)\n\t}\n\treturn nil\n}","typeGuard":"func executableResolvable() bool { _, err := os.Stat(\"/proc/self/exe\"); return err == nil }","tryCatchPattern":"if _, err := os.Executable(); err != nil {\n\treturn fmt.Errorf(\"cannot install service: executable path unresolved (%v); ensure the binary still exists and /proc is mounted\", err)\n}","preventionTips":["Never run `service install` from a binary in /tmp or other volatile locations.","Install the binary to a stable path (e.g. /usr/local/bin) first.","Ensure /proc is mounted in containers/chroots before service install.","Don't delete/replace the binary while the install command runs."],"tags":["linux","service","os-executable","cloudflared"],"backgroundTag":"file-not-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}