{"record":{"id":"3bed8448caa19196","repo":"puppetlabs/puppet","slug":"could-not-find-init-script-for-name","errorCode":null,"errorMessage":"Could not find init script for '#{name}'","messagePattern":"Could not find init script for '#(.+?)'","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/service/init.rb","lineNumber":157,"sourceCode":"  def search(name)\n    paths.each do |path|\n      fqname = File.join(path, name)\n      if Puppet::FileSystem.exist? fqname\n        return fqname\n      else\n        debug(\"Could not find #{name} in #{path}\")\n      end\n    end\n\n    paths.each do |path|\n      fqname_sh = File.join(path, \"#{name}.sh\")\n      if Puppet::FileSystem.exist? fqname_sh\n        return fqname_sh\n      else\n        debug(\"Could not find #{name}.sh in #{path}\")\n      end\n    end\n    raise Puppet::Error, \"Could not find init script for '#{name}'\"\n  end\n\n  # The start command is just the init script with 'start'.\n  def startcmd\n    [initscript, :start]\n  end\n\n  # The stop command is just the init script with 'stop'.\n  def stopcmd\n    [initscript, :stop]\n  end\n\n  def restartcmd\n    (@resource[:hasrestart] == :true) && [initscript, :restart]\n  end\n\n  def service_execute(type, command, fof = true, squelch = false, combine = true)\n    if type == :start && Puppet.runtime[:facter].value('os.family') == \"Solaris\"","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/service/init.rb#L139-L175","documentation":"The init service provider locates the executable by scanning every directory in resource[:path] for a file named exactly <name> (plus a <name>.sh variant); search raises Puppet::Error when no directory yields a hit. This resolution happens lazily via initscript, which startcmd/stopcmd build on, so a service resource with an unresolvable name fails at the point of first command execution rather than at validation time.","triggerScenarios":"Declaring service { 'mydaemon': provider => 'init', path => ['/etc/init.d'] } when /etc/init.d/mydaemon does not exist; a name that differs from the script filename (suffixes like .service, dashes vs underscores); a path parameter that no longer includes the directory holding the script.","commonSituations":"Minimal containers/chroots without /etc/init.d; renamed init scripts after a package upgrade; copying a module from Debian (path /etc/init.d) to a platform whose scripts live elsewhere; accidentally using the init provider on a systemd-only host where the script simply is not shipped.","solutions":["List what the provider can see: ls each directory given in the resource's path parameter","Align the resource title with the init script filename exactly (no .service suffix)","Add or fix the path parameter to include the directory that actually contains the script","On EL7+/systemd hosts, use the systemd provider instead of init"],"exampleFix":"# before\nservice { 'nginx-web':\n  ensure   => running,\n  provider => 'init',\n  path     => ['/usr/local/etc/rc.d'],\n}\n\n# after\nservice { 'nginx':\n  ensure   => running,\n  provider => 'init',\n  path     => ['/etc/init.d', '/usr/local/etc/rc.d'],\n}","handlingStrategy":"validation","validationCode":"# fail the run before startcmd resolves\nbash -c 'test -x \"/etc/init.d/${name}\"' || echo \"no init script '${name}' in path — fix name/path\"","typeGuard":null,"tryCatchPattern":"begin\n  provider.start\nrescue Puppet::Error => e\n  warn \"could not resolve init script for #{name}: check path param vs /etc/init.d\"\nend","preventionTips":["Derive service names from the same source as the package that installs the init script (shared data key)","Declare path => explicitly on init-provider services instead of relying on platform defaults","On systemd-only hosts, never select the init provider; confine profiles by os.family/release","Add a lint/CI check that every service title matches an executable in the declared path on target platforms"],"tags":["puppet","init","service","initscript","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}