{"record":{"id":"8c25b2ee9c8f26af","repo":"cloudflare/cloudflared","slug":"rc-update-add-s-default-w","errorCode":null,"errorMessage":"rc-update add %s default: %w","messagePattern":"rc-update add (.+?) default: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/linux_service.go","lineNumber":434,"sourceCode":"\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\n\tswitch {\n\tcase inits.IsSystemd():\n\t\tlog.Info().Msg(\"Using Systemd\")\n\t\terr = uninstallSystemd(log)\n\tcase inits.IsOpenRC():\n\t\tlog.Info().Msg(\"Using OpenRC\")\n\t\terr = uninstallOpenRC(log)","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/linux_service.go#L416-L452","documentation":"This error wraps a failure from `rc-update add cloudflared default` while installing the cloudflared OpenRC service on Gentoo/Alpine-style systems. The rc-update command registers the service script (typically /etc/init.d/cloudflared) into the default runlevel so it starts at boot. cloudflared throws it whenever the rc-update binary exits non-zero, and it wraps the underlying exec error so the root cause (missing binary, permission failure, missing init script) is preserved.","triggerScenarios":"`cloudflared service install` on a Linux distro using OpenRC when runCommand(\"rc-update\", \"add\", cloudflaredOpenRCService, \"default\") returns a non-zero exit status — e.g. rc-update is not installed, the user is not root, or the OpenRC init script was never generated/doesn't exist.","commonSituations":"Running `cloudflared service install` without sudo on Gentoo/Alpine; a minimal container or chroot without a real OpenRC installation; the openrcTemplate.Generate step silently succeeded but the /etc/init.d/cloudflared file was later removed; corrupted or partial OpenRC installation where the default runlevel symlink target is missing.","solutions":["Re-run the install as root (sudo cloudflared service install)","Verify rc-update exists: `which rc-update`; if absent, the distro doesn't use OpenRC — install via systemd or sysv instead, or install OpenRC","Confirm /etc/init.d/cloudflared exists and is executable; if not, fix the template generation step or regenerate with cloudflared service install","Run `rc-update add cloudflared default` manually to see the raw error output","Check the wrapped error (%w) in the message for the exact rc-update exit cause"],"exampleFix":"// before: installing on a non-OpenRC distro fails\n$ cloudflared service install\n// error: rc-update add cloudflared default: exec: \"rc-update\": executable file not found\n// after: use the correct init system or install OpenRC first\n$ sudo cloudflared service install   # on Gentoo/Alpine with OpenRC present","handlingStrategy":"try-catch","validationCode":"// pre-check before running `cloudflared service install` on OpenRC systems\nif _, err := exec.LookPath(\"rc-update\"); err != nil {\n    return errors.New(\"rc-update not found: this system does not use OpenRC; install as root on Gentoo/Alpine\")\n}\nif os.Geteuid() != 0 {\n    return errors.New(\"service install requires root; re-run with sudo\")\n}\nif _, err := os.Stat(\"/etc/init.d/cloudflared\"); err != nil {\n    return fmt.Errorf(\"init script missing; template generation failed: %w\", err)\n}","typeGuard":"func isOpenRCAvailable() bool {\n    if os.Geteuid() != 0 { return false }\n    if _, err := exec.LookPath(\"rc-update\"); err != nil { return false }\n    _, err := os.Stat(\"/etc/init.d/cloudflared\")\n    return err == nil\n}","tryCatchPattern":"// caller-side handling of the install error\nif err := installLinuxService(c); err != nil {\n    var exitErr *exec.ExitError\n    if errors.As(err, &exitErr) {\n        log.Errorf(\"rc-update failed (exit %d); check init script and root privileges: %v\", exitErr.ExitCode(), err)\n    } else if strings.Contains(err.Error(), \"executable file not found\") {\n        log.Error(\"rc-update missing: not an OpenRC system; use systemd/sysv install path\")\n    }\n    return err\n}","preventionTips":["Always run service install/uninstall with sudo","Detect the init system first (systemd vs OpenRC vs sysv) and use the matching install path","Verify the init script was generated before registering it with rc-update","On minimal containers, prefer running cloudflared directly instead of installing a service"],"tags":["linux","openrc","service-install","command-failed"],"backgroundTag":"command-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"}