{"record":{"id":"6049f49329f85862","repo":"puppetlabs/puppet","slug":"no-command-command-defined-for-provider-provi","errorCode":null,"errorMessage":"No command %{command} defined for provider %{provider}","messagePattern":"No command %(.+?) defined for provider %(.+?)","errorType":"exception","errorClass":"Puppet::DevError","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider.rb","lineNumber":134,"sourceCode":"\n  # (see Puppet::Util::Execution.execpipe)\n  def self.execpipe(*args, &block)\n    Puppet::Util::Execution.execpipe(*args, &block)\n  end\n\n  # Returns the absolute path to the executable for the command referenced by the given name.\n  # @raise [Puppet::DevError] if the name does not reference an existing command.\n  # @return [String] the absolute path to the found executable for the command\n  # @see which\n  # @api public\n  def self.command(name)\n    name = name.intern\n\n    command = @commands[name] if defined?(@commands)\n    command = superclass.command(name) if !command && superclass.respond_to?(:command)\n\n    unless command\n      raise Puppet::DevError, _(\"No command %{command} defined for provider %{provider}\") % { command: name, provider: self.name }\n    end\n\n    which(command)\n  end\n\n  # Confines this provider to be suitable only on hosts where the given commands are present.\n  # Also see {Puppet::Confiner#confine} for other types of confinement of a provider by use of other types of\n  # predicates.\n  #\n  # @note It is preferred if the commands are not entered with absolute paths as this allows puppet\n  #   to search for them using the PATH variable.\n  #\n  # @param command_specs [Hash{String => String}] Map of name to command that the provider will\n  #   be executing on the system. Each command is specified with a name and the path of the executable.\n  # @return [void]\n  # @see optional_commands\n  # @api public\n  #","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider.rb#L116-L152","documentation":"Providers declare external commands with commands :name => 'executable'; declarations live in a per-class @commands hash consulted with superclass lookup. Provider.command(name) returns the absolute path found via which(), and raises Puppet::DevError 'No command X defined for provider Y' when the name was never declared. This is a typo or missing declaration, distinct from a declared executable not being found on disk, which fails later in which().","triggerScenarios":"A provider method calls command(:list) but the class declares commands :lslv => 'lslv'; the symbol is misspelled on either side; the declaration exists on a sibling provider class instead of this class or an ancestor.","commonSituations":"Custom provider development; refactors that rename command aliases; copy-paste between providers where declarations were left behind.","solutions":["Add the declaration at the top of the provider class: commands :list => 'lslv'.","Fix the symbol passed to command() so it matches the declaration exactly.","For shared command sets, declare them in a base provider class that both providers inherit from."],"exampleFix":"# before (provider)\ndef self.instances\n  cmd = command(:list)   # Puppet::DevError: No command list defined\nend\n\n# after\ncommands :list => 'lslv'\ndef self.instances\n  cmd = command(:list)\nend","handlingStrategy":"try-catch","validationCode":"declared = {}\nklass = provider.class\nwhile klass && klass < Puppet::Provider\n  declared.merge!(klass.instance_variable_get(:@commands) || {})\n  klass = klass.superclass\nend\nfail 'undeclared command :list' unless declared.key?(:list)","typeGuard":"def declared_command?(provider_class, name)\n  k = provider_class\n  while k\n    return true if (k.instance_variable_get(:@commands) || {}).key?(name)\n    k = k.superclass\n  end\n  false\nend","tryCatchPattern":"begin\n  executable = self.class.command(:list)\nrescue Puppet::DevError => e\n  raise Puppet::Error, \"#{self.class.name}: #{e.message} (declare with commands :list => 'lslv')\"\nend","preventionTips":["Declare every command the provider uses with commands :name => 'exe' before referencing it.","Unit-test providers with a stub for command() so undeclared names surface early.","Keep declaration and call sites spelled identically (symbols, not strings)."],"tags":["puppet","provider","commands","custom-provider"],"backgroundTag":"undeclared-provider-command","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}