Getting Chocolatey Package Management Provider Working on Windows 10 Print E-mail
PowerShell
Written by Darwin Sanoy   
Sunday, February 28, 2016 12:00am

Have you had some frustrating experiences trying to use the new Chocolatey Package Management provider on Windows 10?  Me too!  But I have some tips to help you get it working as well as possible.

Before you get started - if you have installed the RTM version of WMF 5 / PSH 5 on a fresh machine (Feb 24, 2016 re-release) or you have a February patched version of Windows 10, you will not have any of the below problems.  One exception - If you previously worked with the chocolatey provider on a windows instance using the WMF 5 pre-releases (or Windows 10 before Feb updates) - you may still have the problem of not having the 2.8.5.130 version of the Chocolatey provider even after applying the RTM version of WMF 5 - and as far as I know, the Chocolatey provider does not auto-update.

In my testing it also appears like it is not a good idea to install and actively use both the regular Chocolate Client and the WMF 5 Chocolatey provider.  It could be some facet of my configuration, but I have experienced it on multiple OS versions on clean VMs.  The Chocolatey dev team appears to be working to make both modes use the same code base - but that is a while off.

When doing some initial playing with the WMF 5 Chocolatey provider I was getting these weird behaviors:

  • Install operation ends with success, package shows as installed - no actual software installed.
  • Listing all packages with "Get-Package" does not show chocolatey installed packages.
  • List all packages with "Get-Package" does show chocolatey packages, but shows a blank "Provider" instead of showing "Chocolatey"
  • Trying to uninstall an installed chocolatey package results in an error message.

If you have Windows 10 on real hardware and it has been running for some weeks before you try to use the Chocolatey provider for Windows Package Management - then you will read this and say "I didn't have these problems!"  The same is true of loading the PowerShell 5 Production Preview or later on other OSes.  These problems are resolved when Windows 10 Update updates PowerShell and the PackageManagement provider.

So why write?  If you're like me you might have a library of trial VMs for testing.  You may also typically take pains to disable Windows Updates or the fact that you regularly restart from an unpatched baseline resets your patch level to RTM.  So if you are doing a feasibility study on WMF 5 / PSH 5 Package Management from a VM library you could come to the conclusion that it is more broken than it really is.

You should understand that even after you use the below steps to resolve the issues, that the Chocolatey Package Management provider was turned over to the open source community and hasn't been in active development until relatively recently.  So if you are already into Chocolatey big time - you will notice things are a little rough and bare metalish in the current provider - but the Chocolatey dev team is now working with the provider and will be making sure that it eventually shares the code base of the Chocolatey client.

If you boot up a fresh RTM copy of Windows 10 and open PowerShell you will likely find the following runtime levels:

> $psversiontable
Shows powershell is 5.0.10240.16384 (anything less than 5.0.10586.63)
Resolution: Run Windows Update 

> Get-Module PackageManagement -ListAvailable | Select Name, Version, ModuleBase
Shows Version 1.0.0.0 
(FYI if you show more than one entry and one is 1.0.0.0 - you may want to remove the lower version.)
FYI - If you are running PowerShell Production Preview, your PackageManagement will still be at 1.0.0.0
Resolution: Run Windows Update 

> Get-Command -Module PackageManagement
List shows only 10 commands and is missing Find-PackageProvider, Import-PackageProvider and Install-PackageProvider
Resolution: Run Windows Update 

> Get-PackageProvider Chocolatey | select Name, Version, ProviderPath | fl
Shows a version less than 2.8.5.130
Also version 2.8.5.22 points to "nuget-anycpu.exe" which is not sufficient to process chocolateypackages.
Version 2.8.5.130 points to "chocolateyprovider.exe"
Windows Update won't update this open source PackageManagement plugin - you must do it seperately.
Resolution: Run 'Install-PackageProvider chocolatey -Forcebootstrap'

So to make sure you have the best possible experience you would need to:

1. Run Windows Update (to get the lastest PowerShell and PackageManagement)
2. In an elevated PowerShell Prompt run  'Install-PackageProvider chocolatey -Forcebootstrap'
3. If it's a VM, resnapshot it so you don't keep running into this. 

At a minimum you should have not problems with the list at the start of this article.