chocolatey / choco

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

Weird behavior when installing local packages with a special filename #3418

Closed afroewis closed 2 months ago

afroewis commented 2 months ago

Checklist

What You Are Seeing?

Chocolatey v2.2.2
Installing the following packages:
foo-cc
By installing, you accept licenses for the packages.
Need to add specific handling for exception type NuGetResolverInputException
Unable to find package 'hvi-cc'. Existing packages must be restored before performing an install or update.

Chocolatey installed 0/0 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

What is Expected?

I expect the chocolate to find and install the package

How Did You Get This To Happen?

I am installing a package from a local source.

My command; choco install foo-cc --source 'C:\temp\bad' -Y --force

When I rename foo-cc.24.5.24095.5.nupkg to foo.nupkg, the installation works. Is this behavior intended?

System Details

Installed Packages

chocolatey 2.2.2
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-windowsupdate.extension 1.0.5
foo-cc 24.5.24095.4
KB2919355 1.0.20160915
KB2919442 1.0.20160915
KB2999226 1.0.20181019
KB3033929 1.0.5
KB3035131 1.0.3
neovim 0.9.5
vcredist140 14.38.33135
vcredist2015 14.0.24215.20170201

Output Log

Installing the following packages:
foo-cc
By installing, you accept licenses for the packages.
foo-cc v24.5.24095.4 already installed. Forcing reinstall of version '24.5.24095.4'.
 Please use upgrade if you meant to upgrade to a new version.
foo-cc not installed. The package was not found with the source(s) listed.
 Source(s): 'C:\temp\bad'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - foo-cc - foo-cc not installed. The package was not found with the source(s) listed.
 Source(s): 'C:\temp\bad'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.
PS C:\Windows\system32> choco install foo-cc --source 'C:\temp\bad' -Y --force -d
Chocolatey v2.2.2
Chocolatey is running on Windows v 10.0.22631.0
Command line: "C:\ProgramData\chocolatey\choco.exe" install foo-cc --source C:\temp\bad -Y --force -d
Received arguments: install foo-cc --source C:\temp\bad -Y --force -d
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:\temp\bad' 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='install'|
CacheLocation='C:\Users\AndreasFröwis\AppData\Local\Temp\chocolatey'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='C:\temp\bad'|SourceType='normal'|ShowOnlineHelp='False'|
Debug='True'|Verbose='False'|Trace='False'|Force='True'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='False'|
DisableCompatibilityChecks='False'|AcceptLicense='True'|
AllowUnofficialBuild='False'|Input='foo-cc'|AllVersions='False'|
SkipPackageInstallProvider='False'|SkipHookScripts='False'|
PackageNames='foo-cc'|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.22631.0'|
Information.PlatformName='Windows 10'|
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='AndreasFröwis'|
Information.UserDomainName='AzureAD'|
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:\Windows\system32'|
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:ChocolateyInstallCommand - Normal Run Mode _
Installing the following packages:
foo-cc
By installing, you accept licenses for the packages.
Running list with the following filter = ''
Resolving resource PackageSearchResource for source C:\ProgramData\chocolatey\lib
chocolatey 2.2.2
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-windowsupdate.extension 1.0.5
foo-cc 24.5.24095.4
KB2919355 1.0.20160915
KB2919442 1.0.20160915
KB2999226 1.0.20181019
KB3033929 1.0.5
KB3035131 1.0.3
neovim 0.9.5
vcredist140 14.38.33135
vcredist2015 14.0.24215.20170201
foo-cc v24.5.24095.4 already installed. Forcing reinstall of version '24.5.24095.4'.
 Please use upgrade if you meant to upgrade to a new version.
Resolving resource PackageMetadataResource for source C:\temp\bad
foo-cc not installed. The package was not found with the source(s) listed.
 Source(s): 'C:\temp\bad'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - foo-cc - foo-cc not installed. The package was not found with the source(s) listed.
 Source(s): 'C:\temp\bad'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.
Exiting with 1

Additional Context

No response

pauby commented 2 months ago

choco install foo-cc --source 'C:\temp\bad1' -Y --force -d

You mentioned that the package is in the C:\temp\bad folder. But you specified the source as C:\temp\bad1?

afroewis commented 2 months ago

Sorry, that was a typo when writing the issue. In my extensive tests, the correct directory was used. I will edit my issue to remove this confusion.

pauby commented 2 months ago

I can't reproduce the issue here (note there are no issues with having '-' in the package name):

image

Note that my package above is empty and doesn't have any Chocolatey scripts. Can you provide your package?

afroewis commented 2 months ago

Thanks for your efforts so far. Did you use filename that contains dots (like foo-cc.24.5.24095.5.nupkg?)

I can't provide my package (secret stuff), but I will try to reproduce it with an empty package this weekend!

pauby commented 2 months ago

The dots are the version number. The filename of the package was foo-cc.24.5.24095.5.nupkg.

afroewis commented 2 months ago

I tried to reproduce the problem but didn't succeed. When renaming the file, the installation still fails. That's weird. I am convinced it was that way.

However, I looked more into this issue and I found out that my problem is related to the version of the package.

I have two files:

First, I install version 1.2.0 without any problems: choco install ClassLibrary1 --source "C:\temp\foo" -f -y

Then, I try to install version 1.3.0: choco install ClassLibrary1 --source "C:\temp\<path-to-1-3>" -f -y

Output:

choco install ClassLibrary1 --source "C:\temp\foo" -f -y
Chocolatey v2.2.2
Installing the following packages:
ClassLibrary1
By installing, you accept licenses for the packages.
ClassLibrary1 v1.2.0 already installed. Forcing reinstall of version '1.2.0'.
 Please use upgrade if you meant to upgrade to a new version.
ClassLibrary1 not installed. The package was not found with the source(s) listed.

My expectation was that when using --force , it will install the package in the folder, even though a different version of it is already installed.

pauby commented 2 months ago

What happens when you do what the message suggests and use upgrade?

--force installs the same version again in this case. Note that using --force is not recommended as, as this case demonstrates, it will not do what you think.

afroewis commented 2 months ago

When using upgrade, it upgrades the package if the version in the source folder is newer than the installed one.

I also noticed that the installation works if I provide the version with --version. With this switch, I can even install older versions.

I guess I just shouldn't use --force. Thanks for your help.

pauby commented 2 months ago

I can even install older versions.

Note that you need to add --allow-downgrade to install older versions over a new version.