{"record":{"id":"fcbcd4dee6682557","repo":"chocolatey/choco","slug":"unable-to-find-package-named-0-1-to-pin-plea","errorCode":null,"errorMessage":"Unable to find package named '{0}'{1} to pin. Please check to ensure it is installed.","messagePattern":"Unable to find package named '(.+?)'(.+?) to pin\\. Please check to ensure it is installed\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs","lineNumber":223,"sourceCode":"            var versionUnspecified = string.IsNullOrWhiteSpace(config.Version);\r\n            NuGetVersion semanticVersion = versionUnspecified ? null : NuGetVersion.Parse(config.Version);\r\n\r\n            var input = config.Input;\r\n            config.Input = config.PinCommand.Name;\r\n            config.Version = semanticVersion.ToFullStringChecked();\r\n            config.ListCommand.ByIdOnly = true;\r\n            var exact = config.ListCommand.Exact;\r\n            config.ListCommand.Exact = true;\r\n            var quiet = config.QuietOutput;\r\n            config.QuietOutput = true;\r\n            var installedPackage = _nugetService.List(config).FirstOrDefault();\r\n            config.ListCommand.Exact = exact;\r\n            config.QuietOutput = quiet;\r\n            config.Input = input;\r\n\r\n            if (installedPackage == null)\r\n            {\r\n                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)));\r\n            }\r\n\r\n            var pkgInfo = _packageInfoService.Get(installedPackage.PackageMetadata);\r\n\r\n            var changeMessage = pkgInfo.IsPinned != addingAPin;\r\n\r\n            pkgInfo.IsPinned = addingAPin;\r\n            _packageInfoService.Save(pkgInfo);\r\n\r\n            if (changeMessage)\r\n            {\r\n                this.Log().Warn(\"Successfully {0} a pin for {1} v{2}.\".FormatWith(addingAPin ? \"added\" : \"removed\", pkgInfo.Package.Id, pkgInfo.Package.Version.ToFullStringChecked()));\r\n            }\r\n            else\r\n            {\r\n                this.Log().Warn(NoChangeMessage);\r\n\r\n                if (config.Features.UseEnhancedExitCodes && Environment.ExitCode == 0)\r","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs#L205-L241","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the package is installed: 'choco list --local-only' and check the exact id.","Correct any typo or case-sensitivity issues in the package name passed to --name.","If specifying --version, ensure it matches an actually installed version.","Install the package first with 'choco install <pkg>' if it is missing."],"exampleFix":"// before\nchoco pin add --name=\"google-chrome\"\n// after\nchoco pin add --name=\"googlechrome\"","handlingStrategy":"validation","validationCode":"// Verify the package is installed before pinning\nvar installed = RunChoco(\"list --local-only --exact \" + packageName);\nif (!installed.Contains(packageName, StringComparison.OrdinalIgnoreCase))\n{\n    Console.Error.WriteLine($\"Package '{packageName}' is not installed; cannot pin.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    RunChoco($\"pin add --name={packageName}\");\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"Unable to find package\"))\n{\n    // package not installed — install first or log warning\n    logger.Warn($\"Cannot pin '{packageName}': not installed.\");\n}","preventionTips":["Run 'choco list --local-only' to confirm the exact package id before pinning.","Match case and spelling of the installed package id."],"tags":["chocolatey","pin-command","package-not-found","local-packages"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}