18

The OneGet PowerShell module should ship with the default repository being Chocolatey. This is shown in the documentation found here. However when I run Get-PackageSource it returns PSGallery and MSPSGallery as the sources.

How can I manually set the package source to Chocolatey?

I have tried running:

Register-PackageSource -Name chocolatey -ProviderName Chocolatey -Location http://chocolatey.org/api/v2/

But it returns a warning saying:

Unable to find package provider 'Chocolatey'

Peter Mortensen
  • 2,318
  • 5
  • 23
  • 24
NoAgenda33
  • 181
  • 1
  • 1
  • 4
  • Are you running the April 2014 or September 2014 preview version of PowerShell 5.0? – Mathias R. Jessen Oct 04 '14 at 19:12
  • Did the answer from erik worked for you? I have exact the same issue and tried eriks command, without an error but also without succes. Still now package repository. I'm running the september version of wmf 5.0 on Win 8.1. –  Oct 10 '14 at 20:09
  • @NoAgenda33: Does "Chocolatey" show in the provider list when you run "Get-PackageProvider"? – DonBecker Apr 09 '15 at 23:01

2 Answers2

16

I was looking for the same. This works on the PowerShell version that comes with Windows 10 TP:

register-packagesource -Name chocolatey -Provider PSModule -Trusted -Location http://chocolatey.org/api/v2/ -Verbose
Peter Mortensen
  • 2,318
  • 5
  • 23
  • 24
Erik Lieben
  • 269
  • 1
  • 4
  • Does this add the new package source as a Chocolatey package source or as a PSModule source? – DonBecker Apr 09 '15 at 23:02
  • 2
    I had to do this on Windows 10 but had to make a small change: the `Provider` must be set to `Chocolatey`. That is: `register-packagesource -Name chocolatey -Provider Chocolatey -Trusted -Location http://chocolatey.org/api/v2/ -Verbose` **Note:** this command was preceded by the following: `Get-PackageProvider -Name chocolatey` – Ivan Muzzolini Sep 22 '16 at 09:02
6

Erik's answer didn't work for me. It gives an error:

register-packagesource : Unable to find package providers (PSModule)

This worked though:

PS> Get-PackageSource -Provider chocolatey

And then this command works (for example):

PS> find-package -name chocolatey -provider chocolatey

For reference, my PowerShell version is:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      0      10586  122
Peter Mortensen
  • 2,318
  • 5
  • 23
  • 24
fiat
  • 797
  • 11
  • 16