{"record":{"id":"9dfacd5515a9a8d0","repo":"puppetlabs/puppet","slug":"could-not-enable-name-output","errorCode":null,"errorMessage":"Could not enable #{name}: #{output}","messagePattern":"Could not enable #(.+?): #(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/service/gentoo.rb","lineNumber":45,"sourceCode":"      return :false\n    end\n\n    line = output.split(/\\n/).find { |l| l.include?(@resource[:name]) }\n\n    return :false unless line\n\n    # If it's enabled then it will print output showing service | runlevel\n    if output =~ /^\\s*#{@resource[:name]}\\s*\\|\\s*(boot|default)/\n      :true\n    else\n      :false\n    end\n  end\n\n  def enable\n    output = update :add, @resource[:name], :default\n  rescue Puppet::ExecutionFailure => e\n    raise Puppet::Error, \"Could not enable #{name}: #{output}\", e.backtrace\n  end\nend\n","sourceCodeStart":27,"sourceCodeEnd":48,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/service/gentoo.rb#L27-L48","documentation":"The Gentoo provider's enable shells out to /sbin/rc-update add <name> default and converts any Puppet::ExecutionFailure into Puppet::Error. As with disable, the interpolated #{output} is nil on this path because the assignment never completed, so the message alone does not carry the underlying rc-update stderr.","triggerScenarios":"enable runs when the init script /etc/init.d/<name> does not exist (rc-update add refuses to register a missing script), the name does not match an installed init script, or rc-update exits non-zero for another reason such as a read-only /etc/runlevels.","commonSituations":"The package that ships the init script is not installed or not applied before the service resource (missing package -> service ordering); renaming an ebuild service; a container image with Gentoo userland but no OpenRC state.","solutions":["Run /sbin/rc-update add <name> default manually and read its stderr","Confirm the init script exists and is executable: test -x /etc/init.d/<name>","Add ordering so the owning package is applied first: Package['<pkg>'] -> Service['<name>']","Verify the resource title equals the init script filename"],"exampleFix":"# before\npackage { 'net-misc/ntp': ensure => installed }\nservice { 'ntpd':\n  enable   => true,\n  provider => 'gentoo',\n}\n\n# after\npackage { 'net-misc/ntp': ensure => installed }\n-> service { 'ntpd':\n  enable   => true,\n  provider => 'gentoo',\n}","handlingStrategy":"validation","validationCode":"# ensure the init script exists before enable is attempted\ntest -x \"/etc/init.d/${name}\" || { echo \"${name}: no init script — install package first\"; exit 1; }","typeGuard":null,"tryCatchPattern":"begin\n  provider.enable\nrescue Puppet::Error => e\n  warn \"rc-update add failed for #{name}; check /etc/init.d/#{name} exists and is valid\"\nend","preventionTips":["Always declare Package[...] -> Service[...] ordering for rc-update-managed services","Never force provider => 'gentoo' off-platform; rely on the os.name confine","After package renames, audit service resource titles against /etc/init.d contents"],"tags":["puppet","gentoo","rc-update","service","enable"],"backgroundTag":"command-execution-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}