{"record":{"id":"023b4b846d662dbd","repo":"chocolatey/choco","slug":"could-not-find-a-command-registered-that-meets-0","errorCode":null,"errorMessage":"Could not find a command registered that meets '{0}'.\n Try choco --help for command reference/help.","messagePattern":"Could not find a command registered that meets '(.+?)'\\.\n Try choco --help for command reference/help\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/runners/GenericRunner.cs","lineNumber":56,"sourceCode":"namespace chocolatey.infrastructure.app.runners\r\n{\r\n    public sealed class GenericRunner\r\n    {\r\n        private ICommand FindCommand(ChocolateyConfiguration config, Container container, bool isConsole, Action<ICommand> parseArgs)\r\n        {\r\n            var commands = container.GetAllInstances<ICommand>();\r\n            var command = commands.Where((c) =>\r\n                {\r\n                    var attributes = c.GetType().GetCustomAttributes(typeof(CommandForAttribute), false);\r\n                    return attributes.Cast<CommandForAttribute>().Any(attribute => attribute.CommandName.IsEqualTo(config.CommandName));\r\n                }).FirstOrDefault();\r\n\r\n            if (command == null)\r\n            {\r\n                //todo: #2581 add a search among other location/extensions for the command\r\n                if (!string.IsNullOrWhiteSpace(config.CommandName))\r\n                {\r\n                    throw new Exception(@\"Could not find a command registered that meets '{0}'.\r\n Try choco --help for command reference/help.\".FormatWith(config.CommandName));\r\n                }\r\n\r\n                if (isConsole)\r\n                {\r\n                    Environment.ExitCode = 1;\r\n                }\r\n            }\r\n            else\r\n            {\r\n                if (parseArgs != null)\r\n                {\r\n                    parseArgs.Invoke(command);\r\n                }\r\n\r\n                if (command.MayRequireAdminAccess())\r\n                {\r\n                    WarnIfAdminAndNeedsElevation(config);\r","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/runners/GenericRunner.cs#L38-L74","documentation":"Thrown by GenericRunner.FindCommand when config.CommandName is non-empty but no registered ICommand implementation has a CommandForAttribute matching that name. Chocolatey uses a DI container to register all commands (install, upgrade, uninstall, etc.) and resolves them by name via attribute lookup. An unrecognized command name means the user typed something Chocolatey cannot dispatch.","triggerScenarios":"Running 'choco instal pkg' (typo in 'install'). Running 'choco deploy pkg' where 'deploy' is not a built-in command. A custom command extension was expected but not registered in the container. Case sensitivity mismatch if IsEqualTo fails (though it is case-insensitive). Running a v3-only command on a v2 build or vice versa.","commonSituations":"Typo or misspelling in the command name. User expects a command from a Chocolatey extension or licensed edition that isn't installed. Command was renamed or removed in a version upgrade. Autocomplete or script passes a wrong command string.","solutions":["Check spelling: run 'choco --help' for the full list of available commands","Verify the command exists in your Chocolatey version (some commands require extensions or licensed editions)","If using a custom extension command, ensure the extension is installed and registered","Update scripts if a command was renamed in a newer Chocolatey version"],"exampleFix":"// before\nchoco instal mypackage\n\n// after\nchoco install mypackage","handlingStrategy":"validation","validationCode":"// Validate command name before execution\nvar knownCommands = new[] { \"install\", \"upgrade\", \"uninstall\", \"list\", \"search\",\n    \"push\", \"pack\", \"new\", \"source\", \"config\", \"feature\", \"pin\", \"outdated\", \"apikey\", \"info\", \"template\", \"export\", \"help\" };\nif (!knownCommands.Contains(commandName.ToLowerInvariant()))\n{\n    Console.Error.WriteLine($\"Unknown command '{commandName}'. Run 'choco --help' for available commands.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    runner.Run(config, container, isConsole, parseArgs);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"Could not find a command\"))\n{\n    logger.Error($\"Unknown command '{config.CommandName}'. Run 'choco --help' for the command list.\");\n    Environment.Exit(1);\n}","preventionTips":["Run 'choco --help' to see all available commands","Double-check command spelling in scripts and automation","Be aware that some commands require licensed editions or extensions","Use tab-completion in interactive shells to avoid typos"],"tags":["command-resolution","di-container","command-args","typo"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}