chocolatey/choco · error · ApplicationException

Unable to find requested template '{0}'

Error message

Unable to find requested template '{0}'

What it means

In the template info/list path, if the requested template name is neither the built-in name nor its override and the template directory was not found, TemplateService throws ApplicationException 'Unable to find requested template'. It only reaches this throw after the built-in/override branches are exhausted.

Source

Thrown at src/chocolatey/infrastructure.app/services/TemplateService.cs:293

            {
                if (templateDirList.Contains(_fileSystem.CombinePaths(ApplicationParameters.TemplatesLocation.ToLowerInvariant(), configuration.TemplateCommand.Name.ToLowerInvariant())))
                {
                    ListCustomTemplateInformation(configuration);
                    if (configuration.TemplateCommand.Name.IsEqualTo(_builtInTemplateName) || configuration.TemplateCommand.Name.IsEqualTo(_builtInTemplateOverrideName))
                    {
                        ListBuiltinTemplateInformation(configuration, isBuiltInTemplateOverridden, isBuiltInOrDefaultTemplateDefault);
                    }
                }
                else
                {
                    if (configuration.TemplateCommand.Name.IsEqualTo(_builtInTemplateName) || configuration.TemplateCommand.Name.IsEqualTo(_builtInTemplateOverrideName))
                    {
                        // We know that the template is not overridden since the template directory was checked
                        ListBuiltinTemplateInformation(configuration, isBuiltInTemplateOverridden, isBuiltInOrDefaultTemplateDefault);
                    }
                    else
                    {
                        throw new ApplicationException("Unable to find requested template '{0}'".FormatWith(configuration.TemplateCommand.Name));
                    }
                }
            }
        }

        protected void ListCustomTemplateInformation(ChocolateyConfiguration configuration)
        {
            var sourceCacheContext = new ChocolateySourceCacheContext(configuration);
            var packageResources = NugetCommon.GetRepositoryResources(configuration, _nugetLogger, _fileSystem, sourceCacheContext);
            var pkg = NugetList.FindPackage(
                    "{0}.template".FormatWith(configuration.TemplateCommand.Name),
                    configuration,
                    _nugetLogger,
                    sourceCacheContext,
                    packageResources);

            var templateInstalledViaPackage = (pkg != null);

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Install the template package (choco install <name>.template)
  2. Run choco template list to see which templates are actually available
  3. Correct the template name spelling/case

Example fix

// before
choco template info nonexistent
// after
choco install mytpl.template
choco template info mytpl
Defensive patterns

Strategy: validation

Validate before calling

var dir = fileSystem.CombinePaths(ApplicationParameters.TemplatesLocation, config.TemplateCommand.Name);
var isBuiltIn = config.TemplateCommand.Name == _builtInTemplateName || config.TemplateCommand.Name == _builtInTemplateOverrideName;
if (!isBuiltIn && !fileSystem.DirectoryExists(dir)) {
    throw new DirectoryNotFoundException($"Template '{config.TemplateCommand.Name}' not found. Run 'choco template list' to see available templates.");
}

Try / catch

try { templateService.List(config); }
catch (ApplicationException ex) when (ex.Message.Contains("Unable to find requested template")) {
    logger.Error(ex.Message); // install template or correct name
}

Prevention

When it happens

Trigger: Running the template info/list command (TemplateCommand.Name) for a name that is not the built-in template, not the override, and not present in the templates location.

Common situations: Querying info for a template that was never installed; a typo in the template name; listing before the template package is installed.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/0c85e002663f81ba. Report an issue: GitHub.