chocolatey/choco · error · ApplicationException
Force dependencies can only be used with force also turned o
Error message
Force dependencies can only be used with force also turned on.
What it means
Thrown by ChocolateyUpgradeCommand.Validate() when configuration.ForceDependencies is true but configuration.Force is false. The --force-dependencies option is a strict subset of --force and requires force to also be enabled to prevent accidental destructive dependency operations. This guard ensures the user has explicitly opted into the broader force behavior before touching dependencies.
Source
Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs:284
configuration.Input = string.Join(" ", unparsedArguments);
configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.ToStringSafe(), unparsedArguments.Where(arg => !arg.StartsWith("-")));
if (configuration.RegularOutput)
{
WarnForRemovedOptions(unparsedArguments.Where(arg => arg.StartsWith("-")), _removedOptions);
}
}
public virtual void Validate(ChocolateyConfiguration configuration)
{
if (string.IsNullOrWhiteSpace(configuration.PackageNames))
{
throw new ApplicationException("Package name is required. Please pass at least one package name to upgrade.");
}
if (configuration.ForceDependencies && !configuration.Force)
{
throw new ApplicationException("Force dependencies can only be used with force also turned on.");
}
if (!string.IsNullOrWhiteSpace(configuration.Input))
{
var unparsedOptionsAndPackages = configuration.Input.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
if (!configuration.Information.IsLicensedVersion)
{
foreach (var argument in unparsedOptionsAndPackages.OrEmpty())
{
var arg = argument.ToLowerSafe();
if (arg.StartsWith("-dir") || arg.StartsWith("--dir") || arg.StartsWith("-install") || arg.StartsWith("--install"))
{
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));
}
}
}
}
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Always pass --force together with --force-dependencies: 'choco upgrade <pkg> --force --force-dependencies'
- In code, set both: configuration.Force = true; configuration.ForceDependencies = true;
- Reconsider whether --force-dependencies is actually needed; it reinstalling all dependencies is rarely necessary
Example fix
// before choco upgrade mypackage --force-dependencies // after choco upgrade mypackage --force --force-dependencies
Defensive patterns
Strategy: validation
Validate before calling
// Validate flag combination before calling the command
if (configuration.ForceDependencies && !configuration.Force)
{
Console.Error.WriteLine("--force-dependencies requires --force to also be enabled.");
return;
} Type guard
public static bool AreForceFlagsConsistent(ChocolateyConfiguration config)
{
// ForceDependencies being true without Force is invalid
return !config.ForceDependencies || config.Force;
} Try / catch
try
{
upgradeCommand.Validate(configuration);
}
catch (ApplicationException ex) when (ex.Message.Contains("Force dependencies"))
{
logger.Error("--force-dependencies requires --force. Re-run with both flags.");
} Prevention
- Always pair --force-dependencies with --force on the command line
- When scripting, set both configuration.Force and configuration.ForceDependencies together
- Consider whether --force-dependencies is truly necessary, as it reinstalls all dependencies
When it happens
Trigger: Running 'choco upgrade <pkg> --force-dependencies' without also passing '--force'. Programmatically setting configuration.ForceDependencies = true without setting configuration.Force = true. The dependency-force flag is parsed and set independently from the force flag, so one can be true while the other is false.
Common situations: User misunderstands --force-dependencies as standalone and forgets --force. Script copies a partial flag set between commands. User expects --force-dependencies to imply --force automatically (it does not).
Related errors
- Force dependencies can only be used with force also turned o
- Package name is required. Please pass at least one package n
- It appears you are attempting to use options that may be onl
- A packages.config file is only used with installs.
- A single apikey command must be listed. Please see the help
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/e3388bdb4f1982b8.
Report an issue: GitHub.