chocolatey/choco · error · ApplicationException

Package name is required. Please pass at least one package n

Error message

Package name is required. Please pass at least one package name to install.

What it means

The install command requires at least one package name. ParseAdditionalArguments builds configuration.PackageNames from non-flag positional tokens; Validate() throws if that value is blank, meaning no package was specified.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs:232

            //todo: #770 package name can be a url / installertype
        }

        public virtual void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)
        {
            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 install.");
            }
            // Need a better check on this before releasing. Issue will be covered by other fixes
            //// investigate https://msdn.microsoft.com/en-us/library/system.io.path.getinvalidpathchars(v=vs.100).aspx
            //if (configuration.PackageNames.Contains(":"))
            //{
            //    throw new ApplicationException("Package name cannot contain invalid characters.");
            //}

            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)
                {

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Pass at least one package name: 'choco install <pkg>'.
  2. In automation, assert the package variable is non-empty before invoking choco.
  3. Ensure names don't accidentally start with '-' so they aren't treated as options.

Example fix

# before
choco install --yes

# after
choco install chocolatey --yes
Defensive patterns

Strategy: validation

Validate before calling

// Ensure at least one non-flag package name.
var packages = tokens.Where(t => !t.StartsWith("-")).ToList();
if (packages.Count == 0)
{
    throw new InvalidOperationException("install requires at least one package name");
}

Prevention

When it happens

Trigger: Running 'choco install' with no package name (only flags/switches), or all positional tokens starting with '-' so they are filtered out.

Common situations: Bare 'choco install'; scripts where the package variable is empty; arguments that were all parsed as options.

Related errors


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