chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.26k stars 900 forks source link

Chocolatey fails to downgrade using local source when not using the `--version` option #3384

Closed sintak123 closed 8 months ago

sintak123 commented 8 months ago

Checklist

What You Are Seeing?

When downgrading a any package with local source the downgrade fails.

What is Expected?

The downgrade is succesfull.

How Did You Get This To Happen?

  1. Install latest version of chocolatey (2.2.2): choco upgrade chocolatey
  2. Download older version of chocolatey: https://chocolatey.org/api/v2/package/chocolatey/1.2.0
  3. "Upgrade" chocolatey using the above package as a source choco upgrade chocolatey -y -source $Source --cache $Cache --force --allow-downgrade Same
  4. Install any other package choco upgrade Company.MyApp -y -source $Source --cache $Cache --force --allow-downgrade
  5. Create Company.MyApp package with a lower version
  6. "Upgrade" Company.MyApp choco upgrade Company.MyApp -y -source $Source --cache $Cache --force --allow-downgrade

System Details

Installed Packages

Chocolatey v2.2.2
7zip.install 23.1.0
advanced-installer 20.2.1
AzureSignTool 3.0.1
chocolatey 2.2.2
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-dotnetfx.extension 1.0.1
chocolatey-visualstudio.extension 1.10.2
chocolatey-windowsupdate.extension 1.0.4
ConfigEncryption 1.0.0
dependency-check 8.1.2
dotnet-6.0-aspnetruntime 6.0.6
dotnet-6.0-runtime 6.0.6
dotnet-6.0-sdk 6.0.301
dotnet-6.0-sdk-3xx 6.0.301
dotnet-aspnetcoremodule-v2 16.0.22138
dotnetfx 4.8.0.20220524
dotnet-sdk 6.0.301
git.install 2.41.0
Company.MyApp 2.5.10
jre8 8.0.321
KB2919355 1.0.20160915
KB2919442 1.0.20160915
KB2999226 1.0.20181019
KB3033929 1.0.5
KB3035131 1.0.3
KB3063858 1.0.0
netfx-4.8 4.8.0.20190930
netfx-4.8-devpack 4.8.0.20190930
nodejs-lts 18.17.0
notepadplusplus.install 8.5.7
nuget.commandline 5.8.1
openjdk 19.0.2
python3 3.10.5
ranorex 10.2.3
rdm 2022.3.23
seq 2023.3.9691
sqlcheck 1.3.0
sqlcodeguard 4.0.0
sqltoolbelt 2022.11.10
vcredist140 14.32.31326
vcredist2015 14.0.24215.20170201
virtualbox 7.0.12
visualstudio2022buildtools 117.2.4
visualstudio2022-workload-manageddesktopbuildtools 1.0.0
visualstudio2022-workload-nodebuildtools 1.0.0
visualstudio2022-workload-officebuildtools 1.0.0
visualstudio2022-workload-webbuildtools 1.0.0
visualstudio-installer 2.0.3

Output Log

PS C:\Users\branch\Desktop\packages> choco upgrade chocolatey -y -source $Source --cache $Cache --force --allow-downgrade --debug --verbose
Chocolatey v2.2.2
Chocolatey is running on Windows v 10.0.20348.0
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
Command line: "C:\ProgramData\chocolatey\choco.exe" upgrade chocolatey -y -source C:\Users\branch\Desktop\packages --cache C:\Users\branch\Desktop\packages --force --allow-downgrade --debug --verbose
Received arguments: upgrade chocolatey -y -source C:\Users\branch\Desktop\packages --cache C:\Users\branch\Desktop\packages --force --allow-downgrade --debug --verbose
RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
Sending message 'PreRunMessage' out if there are subscribers...
[Pending] Removing all pending packages that should not be considered installed...
Performing validation checks.
Global Configuration Validation Checks:
 - Package Exit Code / Exit On Reboot = Checked
System State Validation Checks:
 Reboot Requirement Checks:
 - Pending Computer Rename = Checked
 - Pending Component Based Servicing = Checked
 - Pending Windows Auto Update = Checked
 - Pending File Rename Operations = Ignored
 - Pending Windows Package Installer = Checked
 - Pending Windows Package Installer SysWow64 = Checked
Cache Folder Lockdown Checks:
 - Elevated State = Checked
 - Folder Exists = Checked
 - Folder lockdown = Checked
The source 'C:\Users\branch\Desktop\packages' evaluated to a 'normal' source type

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.
Configuration: CommandName='upgrade'|CacheLocation='C:\Users\branch\Desktop\packages'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='C:\Users\branch\Desktop\packages'|SourceType='normal'|
ShowOnlineHelp='False'|Debug='True'|Verbose='True'|Trace='False'|
Force='True'|Noop='False'|HelpRequested='False'|
UnsuccessfulParsing='False'|RegularOutput='True'|QuietOutput='False'|
PromptForConfirmation='False'|DisableCompatibilityChecks='False'|
AcceptLicense='True'|AllowUnofficialBuild='False'|Input='chocolatey'|
AllVersions='False'|SkipPackageInstallProvider='False'|
SkipHookScripts='False'|PackageNames='chocolatey'|Prerelease='False'|
ForceX86='False'|OverrideArguments='False'|NotSilent='False'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
CacheExpirationInMinutes='30'|AllowDowngrade='True'|
ForceDependencies='False'|PinPackage='False'|
Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.20348.0'|
Information.PlatformName='Windows Server 2016'|
Information.ChocolateyVersion='2.2.2.0'|
Information.ChocolateyProductVersion='2.2.2'|
Information.FullName='choco, Version=2.2.2.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|

Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='True'|
Information.UserName='branch'|Information.UserDomainName='WORK'|
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:\Users\branch\Desktop\packages'|
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'|
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'|
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'|
_ Chocolatey:ChocolateyUpgradeCommand - Normal Run Mode _
Upgrading the following packages:
chocolatey
By upgrading, you accept licenses for the packages.
Running list with the following filter = ''
--- Start of List ---
Resolving resource PackageSearchResource for source C:\ProgramData\chocolatey\lib
7zip.install 23.1.0
advanced-installer 20.2.1
AzureSignTool 3.0.1
chocolatey 2.2.2
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-dotnetfx.extension 1.0.1
chocolatey-visualstudio.extension 1.10.2
chocolatey-windowsupdate.extension 1.0.4
ConfigEncryption 1.0.0
dependency-check 8.1.2
dotnet-6.0-aspnetruntime 6.0.6
dotnet-6.0-runtime 6.0.6
dotnet-6.0-sdk 6.0.301
dotnet-6.0-sdk-3xx 6.0.301
dotnet-aspnetcoremodule-v2 16.0.22138
dotnetfx 4.8.0.20220524
dotnet-sdk 6.0.301
git.install 2.41.0
Company.MyApp 2.5.10
jre8 8.0.321
KB2919355 1.0.20160915
KB2919442 1.0.20160915
KB2999226 1.0.20181019
KB3033929 1.0.5
KB3035131 1.0.3
KB3063858 1.0.0
netfx-4.8 4.8.0.20190930
netfx-4.8-devpack 4.8.0.20190930
nodejs-lts 18.17.0
notepadplusplus.install 8.5.7
nuget.commandline 5.8.1
openjdk 19.0.2
python3 3.10.5
ranorex 10.2.3
rdm 2022.3.23
seq 2023.3.9691
sqlcheck 1.3.0
sqlcodeguard 4.0.0
sqltoolbelt 2022.11.10
vcredist140 14.32.31326
vcredist2015 14.0.24215.20170201
virtualbox 7.0.12
visualstudio2022buildtools 117.2.4
visualstudio2022-workload-manageddesktopbuildtools 1.0.0
visualstudio2022-workload-nodebuildtools 1.0.0
visualstudio2022-workload-officebuildtools 1.0.0
visualstudio2022-workload-webbuildtools 1.0.0
visualstudio-installer 2.0.3
--- End of List ---
Resolving resource ListResource for source C:\Users\branch\Desktop\packages
chocolatey v2.2.2 is newer than the most recent.

Chocolatey upgraded 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Sending message 'PostRunMessage' out if there are subscribers...
Exiting with 0

Additional Context

On the same machine the downgrade worked when the source was the standard one and/or choco version was 1.2.0

pauby commented 8 months ago

What re the values of $Source and $Cache or what values could be used to reproduce this?

Ignore this, it's in the log.

pauby commented 8 months ago

I didn't notice this until I came to reproduce it, but you're not telling Chocolatey CLI which version to downgrade to. You need to specify a --version. See the screenshot below, the first command doesn't provide a version and the second one does.

image

pauby commented 8 months ago

I also tried to use 1.2.0 to downgrade putty after installing it.

image

This also didn't work because I didn't specify a version. When I did specify a version, it worked:

image

So I can't reproduce the issue that you mentioned. The commands you mentioned didn't work because no version was specified, and that's expected behaviour.

pauby commented 8 months ago

Also note that we don't support v1.x of Chocolatey CLI open-source. I know you were using this in your example and may not be using it outside of that, but I wanted to mention it.

sintak123 commented 8 months ago

Thank you for you prompt answer. I will change my script to get the version from the local package and include it in the downgrade. I find it a little redundant, as there is only one version available, but it will work. Thank you again!

sintak123 commented 8 months ago

The issue was solved for my case.

pauby commented 8 months ago

I find it a little redundant, as there is only one version available

Downgrading is not an every day action, and potentially has consequences, depending on the software, versions etc. Being very explicit about what you want to do here, and not having Chocolatey CLI guess or make the decision, is a very deliberate behaviour from us to protect you.