{"record":{"id":"66cb038ae85135e4","repo":"chocolatey/choco","slug":"invalid-argument-0-this-argument-has-been-remov","errorCode":null,"errorMessage":"Invalid argument {0}. This argument has been removed from the list command and cannot be used.","messagePattern":"Invalid argument (.+?)\\. This argument has been removed from the list command and cannot be used\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs","lineNumber":165,"sourceCode":"            config.QuietOutput = true;\r\n\r\n            return _packageService.Count(config);\r\n        }\r\n\r\n        public virtual void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)\r\n        {\r\n            var argumentsWithoutLocalOnly = new List<string>(unparsedArguments.Count);\r\n\r\n            foreach (var argument in unparsedArguments)\r\n            {\r\n                var isUnsupportedArgument = _unsupportedArguments.Contains(argument, StringComparer.OrdinalIgnoreCase);\r\n                var isUnsupportedRegistryProgramsArgument = _unsupportedIncludeRegistryProgramsArguments.Contains(argument, StringComparer.OrdinalIgnoreCase);\r\n\r\n                if (isUnsupportedArgument || isUnsupportedRegistryProgramsArgument)\r\n                {\r\n                    if (configuration.RegularOutput)\r\n                    {\r\n                        throw new ApplicationException(\"Invalid argument {0}. This argument has been removed from the list command and cannot be used.\".FormatWith(argument));\r\n                    }\r\n\r\n                    if (isUnsupportedRegistryProgramsArgument)\r\n                    {\r\n                        configuration.ListCommand.IncludeRegistryPrograms = true;\r\n                    }\r\n\r\n                    this.Log().Warn(ChocolateyLoggers.LogFileOnly, \"Ignoring the argument {0}. This argument is unsupported for locally installed packages.\", argument);\r\n                }\r\n                else\r\n                {\r\n                    argumentsWithoutLocalOnly.Add(argument);\r\n                }\r\n            }\r\n\r\n            configuration.Input = string.Join(\" \", argumentsWithoutLocalOnly);\r\n        }\r\n\r","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs#L147-L183","documentation":"The list command (v2+) is local-only and removed several v1 arguments. ParseAdditionalArguments throws when a token matches the unsupported list (_unsupportedArguments: -l, -lo, --lo, -local, --local, -localonly, --localonly, -local-only, --local-only, -a, -all, --all, -allversions, --allversions, -all-versions, --all-versions, -order-by-popularity, --order-by-popularity) or registry-programs (_unsupportedIncludeRegistryProgramsArguments: -li, -il, -lai, etc.) sets AND configuration.RegularOutput is true. In non-regular output mode these are silently ignored/warned instead.","triggerScenarios":"Running 'choco list -lo', 'choco list --allversions', 'choco list -a', 'choco list -order-by-popularity', or 'choco list -li' with regular output (interactive/normal verbosity).","commonSituations":"Upgrading from Chocolatey v1 scripts that used --local-only or --all-versions; copy-pasting old docs; CI scripts carrying legacy list flags.","solutions":["Drop the removed flag: 'choco list' is already local-only in v2+.","For all versions, use 'choco list --by-id-only' patterns or the appropriate v2 options, removing --allversions.","For registry programs, use the supported --include-programs equivalent rather than -li."],"exampleFix":"# before\nchoco list --local-only --allversions\n\n# after\nchoco list","handlingStrategy":"validation","validationCode":"// Strip/replace removed v1 list flags before invoking v2 'choco list'.\nvar removed = new[] { \"-l\",\"-lo\",\"--lo\",\"-local\",\"--local\",\"-localonly\",\"--localonly\",\n    \"-local-only\",\"--local-only\",\"-a\",\"-all\",\"--all\",\"-allversions\",\"--allversions\",\n    \"-all-versions\",\"--all-versions\",\"-order-by-popularity\",\"--order-by-popularity\",\n    \"-li\",\"-il\",\"-lai\",\"-lia\",\"-ali\",\"-ail\",\"-ial\",\"-ila\" };\nvar clean = tokens.Where(t => !removed.Contains(t, StringComparer.OrdinalIgnoreCase)).ToList();\nRunChoco(\"list \" + string.Join(\" \", clean));","typeGuard":"static bool IsRemovedListFlag(string arg) =>\n    removedFlags.Contains(arg, StringComparer.OrdinalIgnoreCase);","tryCatchPattern":null,"preventionTips":["When migrating from v1, remove --local-only/--allversions/--all/--order-by-popularity from list scripts.","Run 'choco list -?' to learn the v2-supported options.","In non-regular output mode these are only warned, but keep scripts clean anyway."],"tags":["list","arguments","removed","deprecated","v2-migration"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}