{"record":{"id":"c5b95c0042b7d14c","repo":"chocolatey/choco","slug":"it-appears-you-are-attempting-to-use-options-that-c5b95c","errorCode":null,"errorMessage":"It appears you are attempting to use options that may be only available in licensed versions of Chocolatey ('{0}'). There may be ways in the open source edition to achieve what you are looking to do. Please remove the argument and consult the documentation.","messagePattern":"It appears you are attempting to use options that may be only available in licensed versions of Chocolatey \\('(.+?)'\\)\\. There may be ways in the open source edition to achieve what you are looking to do\\. Please remove the argument and consult the documentation\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs","lineNumber":297,"sourceCode":"                throw new ApplicationException(\"Package name is required. Please pass at least one package name to upgrade.\");\r\n            }\r\n\r\n            if (configuration.ForceDependencies && !configuration.Force)\r\n            {\r\n                throw new ApplicationException(\"Force dependencies can only be used with force also turned on.\");\r\n            }\r\n\r\n            if (!string.IsNullOrWhiteSpace(configuration.Input))\r\n            {\r\n                var unparsedOptionsAndPackages = configuration.Input.Split(new[] { \" \" }, StringSplitOptions.RemoveEmptyEntries);\r\n                if (!configuration.Information.IsLicensedVersion)\r\n                {\r\n                    foreach (var argument in unparsedOptionsAndPackages.OrEmpty())\r\n                    {\r\n                        var arg = argument.ToLowerSafe();\r\n                        if (arg.StartsWith(\"-dir\") || arg.StartsWith(\"--dir\") || arg.StartsWith(\"-install\") || arg.StartsWith(\"--install\"))\r\n                        {\r\n                            throw new ApplicationException(\"It appears you are attempting to use options that may be only available in licensed versions of Chocolatey ('{0}'). There may be ways in the open source edition to achieve what you are looking to do. Please remove the argument and consult the documentation.\".FormatWith(arg));\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n\r\n            if (!string.IsNullOrWhiteSpace(configuration.SourceCommand.Username) && string.IsNullOrWhiteSpace(configuration.SourceCommand.Password))\r\n            {\r\n                this.Log().Debug(ChocolateyLoggers.LogFileOnly, \"Username '{0}' provided. Asking for password.\".FormatWith(configuration.SourceCommand.Username));\r\n                System.Console.Write(\"User name '{0}' provided. Password: \".FormatWith(configuration.SourceCommand.Username));\r\n                configuration.SourceCommand.Password = InteractivePrompt.GetPassword(configuration.PromptForConfirmation);\r\n            }\r\n        }\r\n\r\n        public override void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            this.Log().Info(ChocolateyLoggers.Important, \"Upgrade Command\");\r\n            this.Log().Info(@\"\r\nUpgrades a package or a list of packages. If you do not have a package\r","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs#L279-L315","documentation":"Thrown by ChocolateyUpgradeCommand.Validate() when the open-source (non-licensed) edition of Chocolatey detects arguments starting with '-dir' or '-install' in the unparsed input. These arguments map to licensed-edition-only features (directory and install location override). The OSS edition detects this common mistake and directs the user to the documentation rather than silently ignoring the option.","triggerScenarios":"Running 'choco upgrade <pkg> --install-arguments=...' or '--directory=...' on the free/open-source edition where configuration.Information.IsLicensedVersion is false. Passing '-directory' or '-installlocation' type options. Any argument whose lowercase form starts with '-dir', '--dir', '-install', or '--install' triggers this check.","commonSituations":"User follows a tutorial written for Chocolatey for Business (C4B) without realizing the features are licensed-only. User migrates scripts from a licensed environment to an OSS one. User expects --directory to work like --install-directory on the community edition.","solutions":["Remove the licensed-only argument (-dir/--dir/-install/--install) and consult documentation for OSS alternatives","If the feature is required, upgrade to a licensed edition of Chocolatey (Chocolatey for Business)","For install arguments, check if a supported OSS equivalent exists such as --install-arguments (without the licensed --directory prefix)"],"exampleFix":"// before (OSS edition)\nchoco upgrade mypackage --directory=C:\\Custom\n\n// after (OSS edition - remove licensed-only option)\nchoco upgrade mypackage\n\n// or use licensed edition where the option is supported","handlingStrategy":"validation","validationCode":"// Check for licensed-only arguments before invoking the command\nvar licensedOnlyPrefixes = new[] { \"-dir\", \"--dir\", \"-install\", \"--install\" };\nvar hasLicensedArgs = args.Any(a =>\n{\n    var lower = a.ToLowerInvariant();\n    return licensedOnlyPrefixes.Any(p => lower.StartsWith(p));\n});\nif (hasLicensedArgs && !isLicensedVersion)\n{\n    Console.Error.WriteLine(\"Licensed-only arguments detected. Remove them or use a licensed edition.\");\n    return;\n}","typeGuard":"public static bool UsesOnlyOssSupportedArgs(IEnumerable<string> args, bool isLicensed)\n{\n    if (isLicensed) return true;\n    var licensedPrefixes = new[] { \"-dir\", \"--dir\", \"-install\", \"--install\" };\n    return !args.Any(a => licensedPrefixes.Any(p => a.ToLowerInvariant().StartsWith(p)));\n}","tryCatchPattern":"try\n{\n    upgradeCommand.Validate(configuration);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"licensed versions\"))\n{\n    logger.Error(\"The specified arguments require a Chocolatey license. Remove them or upgrade.\");\n}","preventionTips":["Be aware of which arguments are licensed-only before using them in scripts","Test scripts on the OSS edition before deploying to avoid licensed-only argument issues","Consult documentation to find OSS alternatives for licensed features","Check configuration.Information.IsLicensedVersion before setting licensed-only options in code"],"tags":["validation","licensing","command-args","upgrade","licensed-features"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}