chocolatey/choco · error · ApplicationException

Unable to find package named '{0}'{1} to pin. Please check t

Error message

Unable to find package named '{0}'{1} to pin. Please check to ensure it is installed.

What it means

Thrown during pin add/remove execution when the NuGet list query (filtered to local-only, exact match, by-id) returns no installed package matching the given --name (and optionally --version). The service checks that the package is actually installed before toggling its pin flag, and refuses to pin/unpin a package that does not exist locally.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs:223

            var versionUnspecified = string.IsNullOrWhiteSpace(config.Version);
            NuGetVersion semanticVersion = versionUnspecified ? null : NuGetVersion.Parse(config.Version);

            var input = config.Input;
            config.Input = config.PinCommand.Name;
            config.Version = semanticVersion.ToFullStringChecked();
            config.ListCommand.ByIdOnly = true;
            var exact = config.ListCommand.Exact;
            config.ListCommand.Exact = true;
            var quiet = config.QuietOutput;
            config.QuietOutput = true;
            var installedPackage = _nugetService.List(config).FirstOrDefault();
            config.ListCommand.Exact = exact;
            config.QuietOutput = quiet;
            config.Input = input;

            if (installedPackage == null)
            {
                throw new ApplicationException("Unable to find package named '{0}'{1} to pin. Please check to ensure it is installed.".FormatWith(config.PinCommand.Name, versionUnspecified ? "" : " (version '{0}')".FormatWith(config.Version)));
            }

            var pkgInfo = _packageInfoService.Get(installedPackage.PackageMetadata);

            var changeMessage = pkgInfo.IsPinned != addingAPin;

            pkgInfo.IsPinned = addingAPin;
            _packageInfoService.Save(pkgInfo);

            if (changeMessage)
            {
                this.Log().Warn("Successfully {0} a pin for {1} v{2}.".FormatWith(addingAPin ? "added" : "removed", pkgInfo.Package.Id, pkgInfo.Package.Version.ToFullStringChecked()));
            }
            else
            {
                this.Log().Warn(NoChangeMessage);

                if (config.Features.UseEnhancedExitCodes && Environment.ExitCode == 0)

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Verify the package is installed: 'choco list --local-only' and check the exact id.
  2. Correct any typo or case-sensitivity issues in the package name passed to --name.
  3. If specifying --version, ensure it matches an actually installed version.
  4. Install the package first with 'choco install <pkg>' if it is missing.

Example fix

// before
choco pin add --name="google-chrome"
// after
choco pin add --name="googlechrome"
Defensive patterns

Strategy: validation

Validate before calling

// Verify the package is installed before pinning
var installed = RunChoco("list --local-only --exact " + packageName);
if (!installed.Contains(packageName, StringComparison.OrdinalIgnoreCase))
{
    Console.Error.WriteLine($"Package '{packageName}' is not installed; cannot pin.");
}

Try / catch

try
{
    RunChoco($"pin add --name={packageName}");
}
catch (ApplicationException ex) when (ex.Message.Contains("Unable to find package"))
{
    // package not installed — install first or log warning
    logger.Warn($"Cannot pin '{packageName}': not installed.");
}

Prevention

When it happens

Trigger: Running 'choco pin add --name=<pkg>' where <pkg> is not installed locally, or where the specified --version does not match any installed version. The list query uses Exact=true and ByIdOnly=true, so only exact id matches count.

Common situations: Typo in package name, package was uninstalled but user still tries to pin it, or version specified does not match the installed version. Also common after a machine migration where packages are not yet reinstalled.

Related errors


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