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

--pre option isn't passed to "choco.exe list" when using choco_package resource #8722

schaden-fred opened this issue Jul 8, 2019 · 0 comments


None yet
2 participants
Copy link

commented Jul 8, 2019


Using the chocolatey_package resource to deploy a pre-release package, the recipe fails.
Although the --pre option was specified in the resource, it's not passed on correctly when choco list is run. The result is that pre-release packages are not shown. If the only packages available are prerelease, then the recipe fails.

Chef Version


Platform Version

Windows Server 2019 Standard Evaluation
Running in Vagrant from gusztavvargadr/windows-server

Replication Case

  1. Create your own chocolatey server. Build one or more prerelease packages (version number has a suffix with a hyphen and text) and upload them to the server.
  2. Set your test machine to use this server.
  3. Create a recipe with a resource to install the chocolatey package.
    chocolatey_package 'packagename' do
    options '--pre'
    action :upgrade
  4. Run chef on the client.

Client Output

* chocolatey_package[packagename] action upgrade

Error executing actionupgradeon resource 'chocolatey_package[packagename]'

Expected process to exit with [0], but received '2'
---- Begin output of C:\ProgramData\chocolatey/bin/choco.exe list -r packagename ----
---- End output of C:\ProgramData\chocolatey/bin/choco.exe list -r packagename ----
Ran C:\ProgramData\chocolatey/bin/choco.exe list -r packagename returned 2

Stdout is blank because no packages were found. Stderr is blank because according to chocolatey, nothing's gone wrong.

The last line shows the command that was run, and this is where the problem is. Because we passed --pre as an option in our recipe, the command should be
C:\ProgramData\chocolatey/bin/choco.exe list -r --pre packagename


  1. Don't build prerelease packages.
  2. Replace the chocolatey_package resource with a powershell_script resource that runs Chocolatey directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.