chocolatey/choco · error · ApplicationException

License is missing or invalid.

Error message

License is missing or invalid.

What it means

Thrown by GenericRunner.FailOnMissingOrInvalidLicenseIfFeatureSet when the configuration.Features.FailOnInvalidOrMissingLicense flag is enabled, the command is not 'feature'/'features', and config.Information.IsLicensedVersion is false. This feature flag makes Chocolatey fail hard (rather than silently degrade) when licensed functionality is expected but no valid license is present. The feature/'features' command is exempt so users can always manage features including this one.

Source

Thrown at src/chocolatey/infrastructure.app/runners/GenericRunner.cs:170

                    this.Log().Debug("Including sources from chocolatey.config file.");
                }
            }
        }

        public void FailOnMissingOrInvalidLicenseIfFeatureSet(ChocolateyConfiguration config)
        {
            if (!config.Features.FailOnInvalidOrMissingLicense ||
                config.CommandName.TrimSafe().IsEqualTo("feature") ||
                config.CommandName.TrimSafe().IsEqualTo("features")
            )
            {
                return;
            }

            if (!config.Information.IsLicensedVersion)
            {
                throw new ApplicationException("License is missing or invalid.");
            }
        }

        public void Run(ChocolateyConfiguration config, Container container, bool isConsole, Action<ICommand> parseArgs)
        {
            var tasks = container.GetAllInstances<ITask>();
            foreach (var task in tasks)
            {
                task.Initialize();
            }

            FailOnMissingOrInvalidLicenseIfFeatureSet(config);
            HttpsSecurity.Reset();
            EventManager.Publish(new PreRunMessage(config));

            try
            {
                var command = FindCommand(config, container, isConsole, parseArgs);

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Install or renew a valid Chocolatey license file in the expected location
  2. If the license is not needed, disable the feature: 'choco feature disable --name=failOnInvalidOrMissingLicense'
  3. Use 'choco feature' command (which is exempt) to manage the setting regardless of license state
  4. Verify the license file path and format match what Chocolatey expects

Example fix

// before: feature is enabled, no license
choco install mypackage
// throws: License is missing or invalid.

// after: disable the strict check (always works since 'feature' is exempt)
choco feature disable --name=failOnInvalidOrMissingLicense
choco install mypackage
Defensive patterns

Strategy: validation

Validate before calling

// Check license and feature flag before running
if (config.Features.FailOnInvalidOrMissingLicense &&
    !config.Information.IsLicensedVersion &&
    !config.CommandName.IsEqualTo("feature") &&
    !config.CommandName.IsEqualTo("features"))
{
    Console.Error.WriteLine("License required (failOnInvalidOrMissingLicense is enabled). " +
        "Disable with: choco feature disable --name=failOnInvalidOrMissingLicense");
    return;
}

Type guard

public static bool CanRunWithoutLicense(ChocolateyConfiguration config)
{
    if (!config.Features.FailOnInvalidOrMissingLicense) return true;
    if (config.CommandName.TrimSafe().IsEqualTo("feature") ||
        config.CommandName.TrimSafe().IsEqualTo("features")) return true;
    return config.Information.IsLicensedVersion;
}

Try / catch

try
{
    runner.FailOnMissingOrInvalidLicenseIfFeatureSet(config);
}
catch (ApplicationException ex) when (ex.Message.Contains("License is missing"))
{
    logger.Error("No valid license. Disable failOnInvalidOrMissingLicense or install a license.");
    // 'choco feature disable --name=failOnInvalidOrMissingLicense' always works
}

Prevention

When it happens

Trigger: The 'failOnInvalidOrMissingLicense' feature is enabled and the user runs any command other than 'feature'/'features' without a valid Chocolatey license installed. The license file is missing, expired, or corrupted. The license check in Information.IsLicensedVersion returns false due to no license being loaded.

Common situations: Enterprise environment mandates licensed features but the license expired or wasn't deployed to this machine. User enabled the fail-on-license feature as a safety measure but then the license lapsed. Machine was provisioned without the license file. License was installed for a different Chocolatey edition.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/f4928917f2bc0e2e. Report an issue: GitHub.