{"record":{"id":"423d8b9543cdabcf","repo":"cloudflare/cloudflared","slug":"error-generating-openrc-conf-d-template-w","errorCode":null,"errorMessage":"error generating OpenRC conf.d template: %w","messagePattern":"error generating OpenRC conf\\.d template: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/linux_service.go","lineNumber":427,"sourceCode":"\t\t}\n\t}\n\tfor _, i := range [...]string{\"0\", \"1\", \"6\"} {\n\t\tif err := os.Symlink(confPath, \"/etc/rc\"+i+\".d/K02et\"); err != nil {\n\t\t\tcontinue\n\t\t}\n\t}\n\treturn runCommand(\"service\", \"cloudflared\", \"start\")\n}\n\nfunc installOpenRC(templateArgs *ServiceTemplateArgs, autoUpdate bool) error {\n\tif autoUpdate {\n\t\ttemplateArgs.ExtraArgs = append([]string{\"--autoupdate-freq\", \"24h0m0s\"}, templateArgs.ExtraArgs...)\n\t} else {\n\t\ttemplateArgs.ExtraArgs = append([]string{\"--no-autoupdate\"}, templateArgs.ExtraArgs...)\n\t}\n\n\tif err := openrcConfTemplate.Generate(templateArgs); err != nil {\n\t\treturn fmt.Errorf(\"error generating OpenRC conf.d template: %w\", err)\n\t}\n\tif err := openrcTemplate.Generate(templateArgs); err != nil {\n\t\treturn fmt.Errorf(\"error generating OpenRC service template: %w\", err)\n\t}\n\n\tif err := runCommand(\"rc-update\", \"add\", cloudflaredOpenRCService, \"default\"); err != nil {\n\t\treturn fmt.Errorf(\"rc-update add %s default: %w\", cloudflaredOpenRCService, err)\n\t}\n\tif err := runCommand(\"rc-service\", cloudflaredOpenRCService, \"start\"); err != nil {\n\t\treturn fmt.Errorf(\"rc-service %s start: %w\", cloudflaredOpenRCService, err)\n\t}\n\treturn nil\n}\n\nfunc uninstallLinuxService(c *cli.Context) error {\n\tlog := logger.CreateLoggerFromContext(c, logger.EnableTerminalLog)\n\n\tvar err error","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/linux_service.go#L409-L445","documentation":"Returned by installOpenRC (Gentoo/Alpine) when rendering the OpenRC conf.d template fails during Linux service installation. cloudflared generates /etc/conf.d/cloudflared from a Go template using the install arguments; a template generation error means the template could not be created or written, so the service files are incomplete and installation stops before rc-update.","triggerScenarios":"`cloudflared service install` on an OpenRC-based system where openrcConfTemplate.Generate(templateArgs) fails — typically the target conf.d file/directory is not writable (missing root), a filesystem error, or bad template arguments (e.g. empty ExtraArgs or invalid cloudflaredBinaryPath).","commonSituations":"Installing without sudo on Gentoo/Alpine so /etc/conf.d is unwritable; corrupted or manually-modified /etc/conf.d/cloudflared; read-only root filesystem on minimal containers running OpenRC.","solutions":["Run the install as root: `sudo cloudflared service install`.","Ensure /etc/conf.d exists and is writable (mkdir -p /etc/conf.d; check mount is not read-only).","Remove any broken existing /etc/conf.d/cloudflared file and retry.","Verify the binary path and ExtraArgs arguments passed to service install are valid (no empty --path values).","Check the wrapped error (%w cause) in the message for the precise filesystem failure."],"exampleFix":"# before\n$ cloudflared service install\n# ERROR: error generating OpenRC conf.d template: open /etc/conf.d/cloudflared: permission denied\n\n# after\n$ sudo cloudflared service install","handlingStrategy":"try-catch","validationCode":"// Shell preflight before OpenRC install\n[ \"$(id -u)\" -eq 0 ] || { echo \"need root\"; exit 1; }\nmkdir -p /etc/conf.d && touch /etc/conf.d/.wtest && rm /etc/conf.d/.wtest || { echo \"/etc/conf.d not writable\"; exit 1; }","typeGuard":null,"tryCatchPattern":"// Go\nout, err := exec.Command(\"cloudflared\", \"service\", \"install\").CombinedOutput()\nif err != nil && strings.Contains(string(out), \"error generating OpenRC conf.d template\") {\n    return fmt.Errorf(\"OpenRC conf.d generation failed; check /etc/conf.d permissions and root access: %s\", out)\n}","preventionTips":["Run service installs on Gentoo/Alpine as root","Verify /etc/conf.d exists and the root filesystem is writable before installing","Delete manually-edited or corrupt /etc/conf.d/cloudflared before reinstalling","Read the wrapped cause in the error message to distinguish permission vs filesystem errors"],"tags":["cli","openrc","service-install","template","linux"],"backgroundTag":"file-write-failed","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"}