Skip to content

[Bug]: Get-ChocoLatestPackage will not work with Chocolatey v2.0.0 and newer #187

@corbob

Description

@corbob

PowerShell Version

Both 5.1 and 7.x

Operating System

Windows

Module Version

Latest

What happened?

Get-ChocoLatestPackage is using choco list to search for the latest version of a package. When provided with a source this will not work at all, and when not provided a source it will return the package version currently installed.

Expected behavior

This should ideally work on the latest supported version of Chocolatey.

Minimal reproduction

I have merely looked at the code: https://github.com/PowerShellOrg/PSDepend/blob/main/PSDepend/PSDependScripts/Chocolatey.ps1#L98. To verify the Chocolatey execution: choco list glab.portable --limit-output --exact --source="chocolatey" is the command that it would run, and this results in When using the '--source' option with the 'choco list' command, only a named alternative source can be provided. Without a source it would result in calling choco list glab --limit-output --exact which works, but list only shows the installed packages.

Error output / logs


Additional context

Some information on the changes can be found here: https://docs.chocolatey.org/en-us/guides/upgrading-to-chocolatey-v2-v6/#querying-remote-sources

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions