Force reinstall of pinned package fails
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist
- [x] I confirm there are no unresolved issues reported on the [Chocolatey Status page](https://status.chocolatey.org).
- [x] I have verified this is the correct repository for opening this issue.
- [x] I have verified no other issues exist related to my problem.
- [x] I have verified this is not an issue for a specific package.
- [x] I have verified this issue is not security related.
- [x] I confirm I am using **official**, and **not** unofficial, or modified, Chocolatey products.
### What You Are Seeing?
If you pin a package, then try to reinstall the package with `choco install --force`, the installation fails and the error message is unhelpful.
NuGet message reported:
```
Need to add specific handling for exception type NuGetResolverInputException
Unable to find package 'test'. Existing packages must be restored before performing an install or update.
```

### What is Expected?
Either:
1. Package reinstalled successfully.
2. Package fails to reinstall with a message that the package is pinned.
### How Did You Get This To Happen?
1. Install a package (`choco install glab`)
2. Pin the package (`choco pin add --name glab`)
3. Try to reinstall the package (`choco install glab --force`)
(Note: for the log below, I used `test` a local test package I had created.
### System Details
* Operating System: Windows 10
* Windows PowerShell version: 5.1
* Chocolatey CLI Version: 2.4.1
* Chocolatey Licensed Extension version: N/A
* Chocolatey License type: N/A
* Terminal/Emulator: conhost
### Installed Packages
```bash
chocolatey 2.4.1
fiddler 5.0.20245.10105
pureportable 2.0.0
test 1.0.0
```
### Output Log
```bash
2024-12-23 12:04:35,601 5108 [DEBUG] - XmlConfiguration is now operational
2024-12-23 12:04:35,652 5108 [DEBUG] - Adding new type 'CygwinService' for type 'IAlternativeSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,652 5108 [DEBUG] - Adding new type 'CygwinService' for type 'IInstallSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,660 5108 [DEBUG] - Adding new type 'PythonService' for type 'IAlternativeSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'PythonService' for type 'IListSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'PythonService' for type 'IInstallSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'PythonService' for type 'IUninstallSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'RubyGemsService' for type 'IAlternativeSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'RubyGemsService' for type 'IListSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'RubyGemsService' for type 'IInstallSourceRunner' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'SystemStateValidation' for type 'IValidation' from assembly 'choco'
2024-12-23 12:04:35,661 5108 [DEBUG] - Adding new type 'CacheFolderLockdownValidation' for type 'IValidation' from assembly 'choco'
2024-12-23 12:04:35,977 5108 [DEBUG] - Adding new type 'EmptyOrInvalidUrlMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,977 5108 [DEBUG] - Adding new type 'FrameWorkReferencesMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'IconMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'LicenseMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'PackageTypesMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'ReadmeMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'RepositoryMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'RequireLicenseAcceptanceMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'ServicableMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Adding new type 'VersionMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Registering new command 'cache' in assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Registering new command 'list' in assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Registering new command 'rule' in assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Registering new command 'template' in assembly 'choco'
2024-12-23 12:04:35,990 5108 [DEBUG] - Registering new command 'export' in assembly 'choco'
2024-12-23 12:04:36,003 5108 [DEBUG] - Registering new command 'info' in assembly 'choco'
2024-12-23 12:04:36,004 5108 [DEBUG] - Registering new command 'help' in assembly 'choco'
2024-12-23 12:04:36,004 5108 [DEBUG] - Registering new command 'config' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'feature' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'new' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'outdated' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'pack' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'pin' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'push' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'apikey' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'source' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'uninstall' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'upgrade' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'search' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'unpackself' in assembly 'choco'
2024-12-23 12:04:36,005 5108 [DEBUG] - Registering new command 'install' in assembly 'choco'
2024-12-23 12:04:36,082 5108 [INFO ] - ============================================================
2024-12-23 12:04:36,475 5108 [INFO ] - Chocolatey v2.4.1
2024-12-23 12:04:36,489 5108 [DEBUG] - Chocolatey is running on Windows v 10.0.19043.0
2024-12-23 12:04:36,489 5108 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2024-12-23 12:04:36,489 5108 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2024-12-23 12:04:36,489 5108 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" install test -s . --force
2024-12-23 12:04:36,489 5108 [DEBUG] - Received arguments: install test -s . --force
2024-12-23 12:04:36,536 5108 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2024-12-23 12:04:36,536 5108 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2024-12-23 12:04:36,536 5108 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2024-12-23 12:04:36,586 5108 [DEBUG] - Performing validation checks.
2024-12-23 12:04:36,599 5108 [DEBUG] - Global Configuration Validation Checks:
2024-12-23 12:04:36,599 5108 [DEBUG] - - Package Exit Code / Exit On Reboot = Checked
2024-12-23 12:04:36,599 5108 [DEBUG] - System State Validation Checks:
2024-12-23 12:04:36,599 5108 [DEBUG] - Reboot Requirement Checks:
2024-12-23 12:04:36,599 5108 [DEBUG] - - Pending Computer Rename = Checked
2024-12-23 12:04:36,599 5108 [DEBUG] - - Pending Component Based Servicing = Checked
2024-12-23 12:04:36,599 5108 [DEBUG] - - Pending Windows Auto Update = Checked
2024-12-23 12:04:36,599 5108 [DEBUG] - - Pending File Rename Operations = Ignored
2024-12-23 12:04:36,599 5108 [DEBUG] - - Pending Windows Package Installer = Checked
2024-12-23 12:04:36,599 5108 [DEBUG] - - Pending Windows Package Installer SysWow64 = Checked
2024-12-23 12:04:36,599 5108 [DEBUG] - Cache Folder Lockdown Checks:
2024-12-23 12:04:36,599 5108 [DEBUG] - - Elevated State = Checked
2024-12-23 12:04:36,614 5108 [DEBUG] - - Folder Exists = Checked
2024-12-23 12:04:36,614 5108 [DEBUG] - - Folder lockdown = Checked
2024-12-23 12:04:36,614 5108 [INFO ] - 3 validations performed. 3 success(es), 0 warning(s), and 0 error(s).
2024-12-23 12:04:36,614 5108 [DEBUG] - The source '.' evaluated to a 'normal' source type
2024-12-23 12:04:36,631 5108 [DEBUG] -
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
output to a gist for review.
2024-12-23 12:04:36,631 5108 [DEBUG] - Configuration: CommandName='install'|
CacheLocation='C:\Users\vagrant\AppData\Local\Temp\chocolatey'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='.'|ExplicitSources='.'|SourceType='normal'|
IncludeConfiguredSources='False'|ShowOnlineHelp='False'|Debug='False'|
Verbose='False'|Trace='False'|Force='True'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|
DisableCompatibilityChecks='False'|AcceptLicense='False'|
AllowUnofficialBuild='False'|Input='test'|AllVersions='False'|
SkipPackageInstallProvider='False'|SkipHookScripts='False'|
PackageNames='test'|Prerelease='False'|ForceX86='False'|
OverrideArguments='False'|NotSilent='False'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
CacheExpirationInMinutes='30'|AllowDowngrade='False'|
ForceDependencies='False'|PinPackage='False'|
Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.19043.0'|
Information.PlatformName='Windows 10'|
Information.ChocolateyVersion='2.4.1.0'|
Information.ChocolateyProductVersion='2.4.1'|
Information.FullName='choco, Version=2.4.1.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|
Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='True'|
Information.UserName='vagrant'|Information.UserDomainName='WINDOWS10'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|
Information.IsLicensedAssemblyLoaded='False'|
Information.LicenseType='Foss'|Information.CurrentDirectory='C:\tmp'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.UsePackageHashValidation='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
ListCommand.ExplicitPageSize='False'|
ListCommand.ExplicitSource='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
UpgradeCommand.IgnorePinned='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='Unknown'|
ApiKeyCommand.Command='Unknown'|PinCommand.Command='Unknown'|
OutdatedCommand.IgnorePinned='False'|
ExportCommand.IncludeVersionNumbers='False'|Proxy.BypassOnLocal='True'|
TemplateCommand.Command='unknown'|CacheCommand.Command='Unknown'|
CacheCommand.RemoveExpiredItemsOnly='False'|
2024-12-23 12:04:36,631 5108 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
2024-12-23 12:04:36,631 5108 [INFO ] - Installing the following packages:
2024-12-23 12:04:36,647 5108 [INFO ] - test
2024-12-23 12:04:36,647 5108 [INFO ] - By installing, you accept licenses for the packages.
2024-12-23 12:04:36,711 5108 [DEBUG] - Process Tree: Chocolatey CLI => Chocolatey CLI => powershell => explorer
2024-12-23 12:04:36,711 5108 [DEBUG] - Updating User Agent to 'Chocolatey Command Line/2.4.1 (Chocolatey CLI) via NuGet Client/6.4.1 (Microsoft Windows NT 10.0.19043.0)'.
2024-12-23 12:04:36,757 5108 [DEBUG] - Updating Source path from . to C:\tmp
2024-12-23 12:04:36,818 5108 [DEBUG] - Running list with the following filter = ''
2024-12-23 12:04:36,818 5108 [DEBUG] - --- Start of List ---
2024-12-23 12:04:36,833 5108 [DEBUG] - Process Tree: Chocolatey CLI => Chocolatey CLI => powershell => explorer
2024-12-23 12:04:36,833 5108 [DEBUG] - Updating User Agent to 'Chocolatey Command Line/2.4.1 (Chocolatey CLI) via NuGet Client/6.4.1 (Microsoft Windows NT 10.0.19043.0)'.
2024-12-23 12:04:36,833 5108 [DEBUG] - Resolving resource PackageSearchResource for source C:\ProgramData\chocolatey\lib
2024-12-23 12:04:37,005 5108 [DEBUG] - chocolatey 2.4.1
2024-12-23 12:04:37,026 5108 [DEBUG] - fiddler 5.0.20245.10105
2024-12-23 12:04:37,026 5108 [DEBUG] - pureportable 2.0.0
2024-12-23 12:04:37,026 5108 [DEBUG] - test 1.0.0
2024-12-23 12:04:37,034 5108 [DEBUG] - --- End of List ---
2024-12-23 12:04:37,034 5108 [WARN ] - test v1.0.0 already installed. Forcing reinstall of version '1.0.0'.
Please use upgrade if you meant to upgrade to a new version.
2024-12-23 12:04:37,036 5108 [DEBUG] - Resolving resource PackageMetadataResource for source C:\tmp
2024-12-23 12:04:37,056 5108 [DEBUG] - Resolving resource DependencyInfoResource for source C:\tmp
2024-12-23 12:04:37,103 5108 [WARN ] - Need to add specific handling for exception type NuGetResolverInputException
2024-12-23 12:04:37,103 5108 [WARN ] - Unable to find package 'test'. Existing packages must be restored before performing an install or update.
2024-12-23 12:04:37,103 5108 [WARN ] -
Chocolatey installed 0/0 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2024-12-23 12:04:37,114 5108 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2024-12-23 12:04:37,114 5108 [DEBUG] - Exiting with 0
```
### Additional Context
_No response_
Contributor guide
Research direction
Reproduce the reported sequence with `choco install glab`, `choco pin add --name glab`, and `choco install glab --force`, then trace install handling for `NuGetResolverInputException`. Confirm the resulting behavior against the two expected outcomes: successful reinstall or a clear message that the package is pinned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100