chocolatey/choco · error · ApplicationException
Package name cannot point directly to a package manifest fil
Error message
Package name cannot point directly to a package manifest file. Please create a package by running 'choco pack' on the .nuspec file first.
What it means
Thrown as an ApplicationException during ValidatePackageNames when a package name ends with '.nuspec' (NuGetConstants.ManifestExtension). A .nuspec is a package manifest/source file — it must first be packed into a .nupkg using 'choco pack' before it can be installed. Passing a .nuspec directly as a package name to install/upgrade/uninstall is unsupported.
Source
Thrown at src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs:1343
{
var fullPath = _fileSystem.GetFullPath(packageName);
if (!string.IsNullOrWhiteSpace(fullPath) && Uri.TryCreate(fullPath, UriKind.Absolute, out uri))
{
ThrowInvalidPathError(uri.LocalPath, uri.IsUnc, config.CommandName);
}
ThrowInvalidPathError(fullPath, isUncPath: false, commandName: config.CommandName);
}
else
{
throw new ApplicationException("Package name cannot point directly to a local, or remote file. Please use the --source argument and point it to a local file directory, UNC directory path or a NuGet feed instead.");
}
}
else if (packageName.EndsWith(NuGetConstants.ManifestExtension))
{
throw new ApplicationException("Package name cannot point directly to a package manifest file. Please create a package by running 'choco pack' on the .nuspec file first.");
}
}
}
private void ThrowInvalidPathError(string packageName, bool isUncPath, string commandName)
{
var sb = new StringBuilder("Package name cannot be a path to a file ");
if (isUncPath)
{
sb.AppendLine("on a UNC location.")
.AppendLine()
.Append("To ")
.Append(commandName.ToLowerSafe())
.AppendLine(" a file in a UNC location, you may use:");
}
else
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Pack the .nuspec into a .nupkg first: 'choco pack mypackage.nuspec'.
- Then install from the directory containing the packed .nupkg: 'choco install mypackage --source=C:\build\output'.
- If the .nuspec is in the current directory, run 'choco pack' then 'choco install mypackage --source=.'.
Example fix
// before: trying to install directly from a manifest choco install mypackage.nuspec // after: pack first, then install choco pack mypackage.nuspec choco install mypackage --source=.
Defensive patterns
Strategy: validation
Validate before calling
// Before calling install/upgrade, validate package names are not .nuspec files
foreach (var name in config.PackageNames.Split(';'))
{
if (name.EndsWith(NuGetConstants.ManifestExtension, StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException(
$"'{name}' is a .nuspec manifest. Pack it first with 'choco pack {name}', then install from the output directory.");
}
} Type guard
public static bool IsValidPackageName(string packageName)
{
return !packageName.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase);
} Try / catch
try
{
_packageService.Install(config);
}
catch (ApplicationException ex) when (ex.Message.Contains("package manifest file"))
{
logger.Error("Cannot install .nuspec directly. Run 'choco pack' first to create a .nupkg.");
} Prevention
- Always pack .nuspec files into .nupkg before attempting installation.
- Run 'choco pack' in the directory containing the .nuspec to produce the installable .nupkg.
- Validate package names to ensure they are plain IDs, not file names.
When it happens
Trigger: Calling install/upgrade/uninstall with config.PackageNames containing a value ending in '.nuspec'. The code checks the extension immediately after the .nupkg branch and throws unconditionally for .nuspec files.
Common situations: A user runs 'choco install mypackage.nuspec' or 'choco install .\mypackage.nuspec' trying to install from a manifest. They need to pack it first: 'choco pack mypackage.nuspec' produces a .nupkg which can then be installed via --source.
Related errors
- No {0} files (or more than 1) were found to build in '{1}'.
- Package name cannot point directly to a local, or remote fil
- Package name cannot be a path to a file
- File specified is either not found or not a {0} file. '{1}'
- One or more issues found with {0}, please fix all validation
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/e34db8a7d600c6be.
Report an issue: GitHub.