chocolatey/choco · error · ApplicationException
Name is required. Please pass in a name for the new package.
Error message
Name is required. Please pass in a name for the new package.
What it means
The new command generates a package skeleton and needs a package name. Validate() throws if configuration.NewCommand.Name is blank, because there is no identifier for the generated nuspec/folder. The name is resolved in ParseAdditionalArguments from the first non-flag, non-'key=value' positional token.
Source
Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs:109
var propValue = property[1].TrimSafe().UnquoteSafe();
if (configuration.NewCommand.TemplateProperties.ContainsKey(propName))
{
this.Log().Warn(() => "A value for '{0}' has already been added with the value '{1}'. Ignoring {0}='{2}'.".FormatWith(propName, configuration.NewCommand.TemplateProperties[propName], propValue));
}
else
{
configuration.NewCommand.TemplateProperties.Add(propName, propValue);
}
}
}
}
public virtual void Validate(ChocolateyConfiguration configuration)
{
if (string.IsNullOrWhiteSpace(configuration.NewCommand.Name))
{
throw new ApplicationException("Name is required. Please pass in a name for the new package.");
}
if (configuration.NewCommand.Name.StartsWith("-file", StringComparison.OrdinalIgnoreCase) || configuration.NewCommand.Name.StartsWith("--file", StringComparison.OrdinalIgnoreCase))
{
throw new ApplicationException(@"Automatic package creation from installer files only available in Business
edition. See https://chocolatey.org/compare for details.");
}
}
public virtual void HelpMessage(ChocolateyConfiguration configuration)
{
this.Log().Info(ChocolateyLoggers.Important, "New Command");
this.Log().Info(@"
Chocolatey will generate package specification files for a new package.
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Pass a name positionally: 'choco new MyPackage'.
- In automation, assert the name variable is non-empty before invoking choco new.
- Ensure the name token doesn't start with '-' or contain '=' so it is recognized as the name.
Example fix
# before choco new Version=1.0 # after choco new MyPackage Version=1.0
Defensive patterns
Strategy: validation
Validate before calling
// Ensure a non-empty name before 'choco new'.
if (string.IsNullOrWhiteSpace(name) || name.StartsWith("-") || name.Contains("="))
{
throw new InvalidOperationException("choco new requires a package name (no leading '-', no '=')");
}
RunChoco($"new {name}"); Prevention
- Always pass a plain package name as the first positional token to 'choco new'.
- Don't lead the command with template properties (Version=...); put the name first.
- Assert the name variable is non-empty in automation.
When it happens
Trigger: Running 'choco new' with no positional name (only flags/properties like Version=1.0), or where every positional token starts with '-' or contains '='.
Common situations: Bare 'choco new'; scripts where the name variable is empty; passing only template properties without a name.
Related errors
- When specifying the subcommand '{0}', you must also specify
- When specifying the subcommand '{0}', you must also specify
- A single apikey command must be listed. Please see the help
- You must specify 'source' to remove an API key.
- You must specify both 'source' and 'key' to set an API key.
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/57f59243adcf5777.
Report an issue: GitHub.