{"record":{"id":"23fd561f4bf142ec","repo":"chocolatey/choco","slug":"force-dependencies-can-only-be-used-with-force-als","errorCode":null,"errorMessage":"Force dependencies can only be used with force also turned on.","messagePattern":"Force dependencies can only be used with force also turned on\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs","lineNumber":243,"sourceCode":"            }\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (string.IsNullOrWhiteSpace(configuration.PackageNames))\r\n            {\r\n                throw new ApplicationException(\"Package name is required. Please pass at least one package name to install.\");\r\n            }\r\n            // Need a better check on this before releasing. Issue will be covered by other fixes\r\n            //// investigate https://msdn.microsoft.com/en-us/library/system.io.path.getinvalidpathchars(v=vs.100).aspx\r\n            //if (configuration.PackageNames.Contains(\":\"))\r\n            //{\r\n            //    throw new ApplicationException(\"Package name cannot contain invalid characters.\");\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","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs#L225-L261","documentation":"ForceDependencies is only meaningful alongside Force. Validate() throws when configuration.ForceDependencies is true but configuration.Force is false, because forcing dependency operations without forcing the primary operation is unsupported and can leave inconsistent state.","triggerScenarios":"Running 'choco install <pkg> --forcedependencies' (or -x without --force), setting ForceDependencies without also setting Force.","commonSituations":"Passing --force-dependencies alone expecting it implies --force; scripts carrying over only one of the two flags; config that sets forceDependencies but not force.","solutions":["Always pair --force-dependencies with --force: 'choco install <pkg> --force --forcedependencies'.","Drop --force-dependencies if you only want to force the primary package.","Review chocolatey.config to ensure both flags align."],"exampleFix":"# before\nchoco install pkg --forcedependencies\n\n# after\nchoco install pkg --force --forcedependencies","handlingStrategy":"validation","validationCode":"// ForceDependencies requires Force.\nif (forceDependencies && !force)\n{\n    throw new InvalidOperationException(\"--force-dependencies requires --force\");\n}\nvar args = forceDependencies && force ? \"--force --force-dependencies\" : \"\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --force-dependencies as always paired with --force.","Audit chocolatey.config so the two flags are consistent."],"tags":["install","validation","force","dependencies"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}