{"record":{"id":"7a1ab29baddd0115","repo":"puppetlabs/puppet","slug":"module-module-name-not-found-in-environment-e","errorCode":null,"errorMessage":"Module %{module_name} not found in environment %{environment_name}.","messagePattern":"Module %(.+?) not found in environment %(.+?)\\.","errorType":"exception","errorClass":"Puppet::Module::MissingModule","httpStatus":null,"severity":"error","filePath":"lib/puppet/info_service/plan_information_service.rb","lineNumber":22,"sourceCode":"  require_relative '../../puppet/module'\n\n  def self.plans_per_environment(environment_name)\n    # get the actual environment object, raise error if the named env doesn't exist\n    env = Puppet.lookup(:environments).get!(environment_name)\n    env.modules.map do |mod|\n      mod.plans.map do |plan|\n        { :module => { :name => plan.module.name }, :name => plan.name }\n      end\n    end.flatten\n  end\n\n  def self.plan_data(environment_name, module_name, plan_name)\n    # raise EnvironmentNotFound if applicable\n    Puppet.lookup(:environments).get!(environment_name)\n\n    pup_module = Puppet::Module.find(module_name, environment_name)\n    if pup_module.nil?\n      raise Puppet::Module::MissingModule, _(\"Module %{module_name} not found in environment %{environment_name}.\") %\n                                           { module_name: module_name, environment_name: environment_name }\n    end\n\n    plan = pup_module.plans.find { |t| t.name == plan_name }\n    if plan.nil?\n      raise Puppet::Module::Plan::PlanNotFound.new(plan_name, module_name)\n    end\n\n    begin\n      plan.validate\n      { :metadata => plan.metadata, :files => plan.files }\n    rescue Puppet::Module::Plan::Error => err\n      { :metadata => nil, :files => [], :error => err.to_h }\n    end\n  end\nend\n","sourceCodeStart":4,"sourceCodeEnd":39,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/info_service/plan_information_service.rb#L4-L39","documentation":"Puppet::InfoService::PlanInformationService.plan_data resolves the environment (Puppet.lookup(:environments).get! raises separately if missing), then looks up the module with Puppet::Module.find. If no module of that name exists in the environment's modulepath, it raises Puppet::Module::MissingModule with this message. This powers 'puppet plan show' and Puppet Server plan APIs (Bolt orchestration surface).","triggerScenarios":"Calling Puppet::InfoService::PlanInformationService.plan_data('production', 'apache', 'restart') when the apache module is absent from production's modulepath, when the module name is mispelled or wrongly cased (module lookup is case-sensitive on directory names), or when environment.conf modulepath points elsewhere than expected.","commonSituations":"Bolt plan invocations where the plan's module was not deployed to the PE environment; querying a plan in the wrong environment; module directory renamed without updating invocations; Control-repo deploy gaps leaving modulepath empty.","solutions":["Confirm the module directory exists and matches the case: ls $(puppet config print environmentpath)/<env>/modules | grep -i <module>","Verify modulepath resolution for that environment: puppet config print modulepath --section master --environment <env>","Redeploy the control repo / r10k environment so the plan's module is present","Pass the environment that actually contains the module when calling plan_data"],"exampleFix":"# before\nPuppet::InfoService::PlanInformationService.plan_data('production', 'apache', 'restart')\n# => Puppet::Module::MissingModule: Module apache not found in environment production.\n\n# after: module lives under 'site' path in env config\n# environment.conf: modulepath = site:modules:$basemodulepath\nPuppet::InfoService::PlanInformationService.plan_data('production', 'apache', 'restart')\n# with modules/apache/plans/restart.pp deployed under the 'site' dir","handlingStrategy":"validation","validationCode":"env = Puppet.lookup(:environments).get!(environment_name)\nmod = Puppet::Module.find(module_name, environment_name)\nraise Puppet::Module::MissingModule, \"#{module_name} missing from #{environment_name}\" if mod.nil?\nresult = Puppet::InfoService::PlanInformationService.plan_data(environment_name, module_name, plan_name)","typeGuard":null,"tryCatchPattern":"begin\n  data = Puppet::InfoService::PlanInformationService.plan_data(env, mod, plan)\nrescue Puppet::Module::MissingModule\n  data = nil  # or fall back to a known-good environment containing the plan\nend","preventionTips":["Verify module presence (Puppet::Module.find) before calling plan/task data APIs","Automate r10k/Code Manager deploys so plan modules land atomically with plan invocations","Use exact module directory casing in plan names"],"tags":["puppet","plans","bolt","module-resolution","environment"],"backgroundTag":"module-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}