Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Failed to Install-Package with -RequiredVersion option #20

Closed
dougpuob opened this issue Jan 21, 2021 · 4 comments · Fixed by #21
Closed

[Issue] Failed to Install-Package with -RequiredVersion option #20

dougpuob opened this issue Jan 21, 2021 · 4 comments · Fixed by #21

Comments

@dougpuob
Copy link

Hi @jianyunt, thank you for your project. It makes script easier to install packages with choco. I found a tricky behavior, seems like an issue when I Install-Package with the -RequiredVersion option.

❌Failed case

Install-Package -Provider ChocolateyGet -ErrorAction Stop -Verbose -AcceptLicense ninja -RequiredVersion 1.10.2
VERBOSE: Using the provider 'ChocolateyGet' for searching packages.
VERBOSE: Source selected: chocolatey
Install-Package: No match was found for the specified search criteria and package name 'ninja'. Try Get-PackageSource to see all available registered package sources.

✅Passed case

Install-Package -Provider ChocolateyGet -ErrorAction Stop -Verbose -AcceptLicense ninja
VERBOSE: Using the provider 'ChocolateyGet' for searching packages.
VERBOSE: Performing the operation "Install Package" on target "Package 'ninja' version '1.10.2' from 'chocolatey'.".

image

@ethanbergstrom
Copy link
Collaborator

ethanbergstrom commented Jan 23, 2021

Hey @dougpuob,

Glad to hear ChocolateyGet is making life easier for you!

The issue you're describing seems to be more of a quirk with choco itself, rather than ChocolateyGet.

If you run Install-Package or Find-Package with the -debug flag, it will actually list out the command line arguments passed to choco.exe. For ninja 1.10.2, that's choco.exe search ninja --version 1.10.2 --source Chocolatey which also returns no results.

From what I can find, this seems to be related to this choco issue that was opened a while ago, but is now closed and doesn't look like anyone is going to fix it. It looks like most folks are working around the problem by passing the --exact flag to choco, which skips package description text search and assumes your search text is the exact package name you want.

Since ChocolateyGet is going to return whatever choco.exe does, what you'd probably need to run is:
Install-Package ninja -ProviderName ChocolateyGet -RequiredVersion 1.10.2 -AdditionalArguments '--exact'

Hope that works for you!

@ethanbergstrom
Copy link
Collaborator

ethanbergstrom commented Jan 23, 2021

Actually, thinking about this a little more, I think I could make that experience better: to assume --exact behavior if package name and required version are specified.

@ethanbergstrom
Copy link
Collaborator

ethanbergstrom commented Jan 23, 2021

Will need to downgrade the version of the choco Native API DLL to version 0.10.13 due to a different choco issue that won't be fixed until the 0.10.16 API is released in order for the exact behavior to work with the OneGet MinimumVersion\ MaximumVersion\ AllVersions flags.

ethanbergstrom added a commit that referenced this issue Jan 23, 2021
…ion are specified

Changed
* Change default search to use exact package name if both package name and required version are specified (#20)
  * Requires downgrade to Chocolatey 0.10.13 due to [a Chocolatey defect](chocolatey/choco#1843) until 0.10.16 is released

Fixed
* AppVeyor builds no longer fail due to change in build image permissions
* Version min/max comparison should now work properly
@ethanbergstrom
Copy link
Collaborator

@dougpuob,

ChocolateyGet v2.1.0 is now out on PSGallery, and my tests indicate it now works without having to sometimes pass -AdditionalArguments '--exact' depending on how many results match in the repository.

This does however, introduce a possible new with issue with -MaximumVersion and -AllVersion flags that is in turn caused by a defect in Chocolatey itself, but there are a few workarounds available.

Please see the updated documentation in the readme for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants