Choco: list/search/info - searching with --exact or info results in Object reference not set to an instance of an object

Created on 31 May 2019  路  6Comments  路  Source: chocolatey/choco

What You Are Seeing?

Using choco.exe list --exact <missing package name> results in an error with an rc of 1

C:\Windows\system32>choco list --exact some_weird_package
Chocolatey v0.10.14
Object reference not set to an instance of an object.

C:\Windows\system32>echo %ERRORLEVEL%
1

This affects the win_chocolatey module in Ansible as we run choco list --exact --local-only <package name> to test whether a package is installed or not. Unfortunately I cannot see a way around this and so we will start being inundated with GitHub bugs until a new Chocolatey release with this fix is in.

What is Expected?

C:\Windows\system32>choco list --exact some_weird_package
Chocolatey v0.10.11
0 packages found.

C:\Windows\system32>echo %ERRORLEVEL%
0  # or 2 depending on the feature flag

How Did You Get This To Happen? (Steps to Reproduce)

Make sure you are on 0.10.14 and run the command above.

Output Log


Full Log Output

~~~sh C:\Windows\system32>choco list --exact some_weird_package --debug --verbose Chocolatey v0.10.14 Chocolatey is running on Windows v 10.0.17763.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" list --exact some_weird_package --debug --verbose Received arguments: list --exact some_weird_package --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 = Checked - Pending Windows Package Installer = Checked - Pending Windows Package Installer SysWow64 = Checked The source 'https://chocolatey.org/api/v2/' 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='list'| CacheLocation='C:\Users\vagrant\AppData\Local\Temp\chocolatey'| ContainsLegacyPackageInstalls='True'| CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'| Sources='https://chocolatey.org/api/v2/'|SourceType='normal'| Debug='True'|Verbose='True'|Trace='False'|Force='False'|Noop='False'| HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'| QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'| AllowUnofficialBuild='False'|Input='some_weird_package'| AllVersions='False'|SkipPackageInstallProvider='False'| Prerelease='False'|ForceX86='False'|OverrideArguments='False'| NotSilent='False'|ApplyPackageParametersToDependencies='False'| ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'| AllowMultipleVersions='False'|AllowDowngrade='False'| ForceDependencies='False'|Information.PlatformType='Windows'| Information.PlatformVersion='10.0.17763.0'| Information.PlatformName='Windows Server 2016'| Information.ChocolateyVersion='0.10.14.0'| Information.ChocolateyProductVersion='0.10.14'| Information.FullName='choco, Version=0.10.14.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'| Information.Is64BitOperatingSystem='True'| Information.Is64BitProcess='True'|Information.IsInteractive='True'| Information.UserName='vagrant'| Information.UserDomainName='WIN-C8BPPV878V8'| Information.IsUserAdministrator='True'| Information.IsUserSystemAccount='False'| Information.IsUserRemoteDesktop='False'| Information.IsUserRemote='True'| Information.IsProcessElevated='True'| Information.IsLicensedVersion='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'| Features.ScriptsCheckLastExitCode='False'| ListCommand.LocalOnly='False'| ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'| ListCommand.PageSize='25'|ListCommand.Exact='True'| ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'| ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'| ListCommand.ApprovedOnly='False'| ListCommand.DownloadCacheAvailable='False'| ListCommand.NotBroken='False'| ListCommand.IncludeVersionOverrides='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.Remove='False'|PinCommand.Command='unknown'| OutdatedCommand.IgnorePinned='False'|Proxy.BypassOnLocal='True'| _ Chocolatey:ChocolateyListCommand - Normal Run Mode _ Searching for package information Running list with the following filter = 'some_weird_package' --- Start of List --- Using 'https://chocolatey.org/api/v2/'. - Supports prereleases? 'True'. - Is ServiceBased? 'True'. Sending message 'PostRunMessage' out if there are subscribers... Chocolatey had an error occur: System.NullReferenceException: Object reference not set to an instance of an object. at chocolatey.infrastructure.app.services.NugetService.<>c__DisplayClass13.b__4() at chocolatey.infrastructure.logging.Log4NetLog.Info(Func`1 message) at chocolatey.infrastructure.app.services.NugetService.d__15.MoveNext() at chocolatey.infrastructure.app.services.ChocolateyPackageService.d__17.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at chocolatey.infrastructure.app.commands.ChocolateyListCommand.run(ChocolateyConfiguration configuration) at chocolatey.infrastructure.app.runners.GenericRunner.run(ChocolateyConfiguration config, Container container, Boolean isConsole, Action`1 parseArgs) at chocolatey.infrastructure.app.runners.ConsoleApplication.run(String[] args, ChocolateyConfiguration config, Container container) at chocolatey.console.Program.Main(String[] args) Exiting with 1 ~~~

3 - Done Bug Priority_HIGH

Most helpful comment

Thank you guys for fix 'Object reference not set to an instance of an object'!

All 6 comments

This also happens for choco info, which produces the following ouput:

> choco info
Chocolatey v0.10.14
Object reference not set to an instance of an object.

Thanks for the quick response on this issue. (The regression caused me a bit of drama this morning and @jborean93 was of great help in getting this addresses quickly)

How can a pre-release build of chocolatey be tested easily?

I downloaded the build artifact for 0f86f78 from AppVeyor and installed the nupkg with choco intall, but I'm not sure if that's the right way to do it?

choco.exe is now barking about a non-official build, which makes sense I guess.

Will there be a pre-release added to the nupkg feed for easier testing?

@cwegener I have actually just released a beta version of chocolatey which you can grab from here:

https://chocolatey.org/packages/chocolatey/0.10.15-beta-20190531

It is still working it's way through the moderation process, but you can grab it directly.

Chocolatey v0.10.15 is being pushed out in the next hour.

Thanks for catching this. I've added an additional scenario to the specs to find this to prevent any future regressions.

Thank you guys for fix 'Object reference not set to an instance of an object'!

Was this page helpful?
0 / 5 - 0 ratings