chocolatey/choco · error · ApplicationException

No rule with the name {0} could be found.

Error message

No rule with the name {0} could be found.

What it means

Thrown by ChocolateyRuleCommand when the command is invoked in 'get' mode (RegularOutput is true) and the specified --name does not match any rule Id in the set of all available rules returned by _ruleService.GetAllAvailableRules(). The lookup uses a case-insensitive equality check (IsEqualTo) on the rule Id. Because ImmutableRule is a struct, the FirstOrDefault never returns null — the code instead checks for an empty Id string.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs:91

                configuration.RuleCommand.Name = unparsedArguments[1];
            }
        }

        public virtual void Run(ChocolateyConfiguration config)
        {
            IEnumerable<ImmutableRule> implementedRules = _ruleService.GetAllAvailableRules().OrderBy(r => r.Id);

            if (!string.IsNullOrEmpty(config.RuleCommand.Name))
            {
                var foundRule = implementedRules.FirstOrDefault(i => i.Id.IsEqualTo(config.RuleCommand.Name));

                // Since the return value is a structure, it will never be null.
                // As such we check that the identifier is not empty.
                if (config.RegularOutput)
                {
                    if (string.IsNullOrEmpty(foundRule.Id))
                    {
                        throw new ApplicationException("No rule with the name {0} could be found.".FormatWith(config.RuleCommand.Name));
                    }

                    // Not using multiline logging here, as it causes issues
                    // with unit tests.
                    this.Log().Info("Name: {0} | Severity: {1}", foundRule.Id, foundRule.Severity);
                    this.Log().Info("Summary: {0}", foundRule.Summary);
                    this.Log().Info("Help URL: {0}", foundRule.HelpUrl);

                    return;
                }
                else if (!string.IsNullOrEmpty(foundRule.Id))
                {
                    implementedRules = new[] { foundRule };
                }
                else
                {
                    return;
                }

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. List all available rules first to find the exact id: 'choco rule list'.
  2. Copy the exact rule id from the list output and retry: 'choco rule get --name=<exact-id>'.
  3. Check rule name case and spelling carefully.

Example fix

// before
choco rule get --name="choco-001"
// after
choco rule list
# find the correct id, e.g. "CHOCO0001"
choco rule get --name="CHOCO0001"
Defensive patterns

Strategy: validation

Validate before calling

// Verify rule exists before 'get'
var rules = RunChoco("rule list");
var ruleNames = ParseRuleNames(rules);
if (!ruleNames.Contains(ruleName, StringComparer.OrdinalIgnoreCase))
{
    Console.Error.WriteLine($"Rule '{ruleName}' does not exist. Available: {string.Join(", ", ruleNames)}");
}

Try / catch

try
{
    RunChoco($"rule get --name={ruleName}");
}
catch (ApplicationException ex) when (ex.Message.Contains("No rule with the name"))
{
    logger.Warn($"Rule '{ruleName}' not found. Run 'choco rule list' for valid ids.");
}

Prevention

When it happens

Trigger: Running 'choco rule get --name=<ruleId>' where <ruleId> does not match any implemented rule's Id. The match is exact (case-insensitive). Typographical errors or referencing a rule that does not exist in the current Chocolatey version triggers this.

Common situations: User copies a rule name from documentation for a different Chocolatey version, or mistypes the rule id. Rule names may change between versions as new rules are added or renamed.

Related errors


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