Chocolatey For Windows

Chocolatey For Windows Rating: 5,7/10 1255 votes

Join GitHub today. GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.

Requirements

  • Windows 7+ / Windows Server 2003+
  • PowerShell v2+ (Not PowerShell Core yet though)
  • .NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)

That's it! All you need is choco.exe (that you get from the installation scripts) and you are good to go! No Visual Studio required.

Installing Chocolatey

Chocolatey installs in seconds. You are just a few steps from running choco right now!

  1. First, ensure that you are using an administrative shell - you can also install as a non-admin, check out Non-Administrative Installation.
  2. Copy the text specific to your command shell - cmd.exe or powershell.exe.
  3. Paste the copied text into your shell and press Enter.
  4. Wait a few seconds for the command to complete.
  5. If you don't see any errors, you are ready to use Chocolatey! Type choco or choco -? now, or see Getting Started for usage instructions.

NOTES:

  • If you are behind a proxy, please see Installing behind a proxy.
  • Need completely offline solution? See Completely Offline Install.
  • Installing the licensed edition? See install licensed edition.
  • More Options / Troubleshooting

Install with cmd.exe

Chocolatey for windows

Run the following command:

Install with PowerShell.exe

With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

  • Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.
  • Now run the following command:

Additional considerations

NOTE: Please inspect https://chocolatey.org/install.ps1 prior to running any of these scripts to ensure safety. We already know it's safe, but you should verify the security and contents of any script from the internet you are not familiar with. All of these scripts download a remote PowerShell script and execute it on your machine.

We take security very seriously. Learn more.

More Install Options

Install from PowerShell v3+

With PowerShell, there is an additional step or two. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

  • Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass.
  • Now run the following command:

Completely offline install

With completely offline use of Chocolatey, you want to ensure you remove the default community package source (choco source list followed by choco source remove -n chocolatey, or however you would do that with a configuration manager like Puppet).

  1. The first step with offline is to obtain a copy of the Chocolatey Nupkg (nupkg files are just fancy zip files). Go to https://chocolatey.org/packages/chocolatey and find a version you want.
  2. Click on Download to download that version's nupkg file.
  1. You can also download the latest version directly.
  2. You can put the chocolatey.nupkg on an internal package repository and then address that full path, similar to how you see in the Puppet provider - https://forge.puppet.com/puppetlabs/chocolatey#manage-chocolatey-installation
  3. Then you would run a script similar to the below to address that local install. If it is on a repository somewhere, you will need to enhance the below script to get that file (the Chocolatey Puppet provider install script shows that).

Install with Puppet

NOTE: If you have the licensed edition, see Setting up Licensed Edition with Puppet instead. This only additionally contains some package examples and setting up tab completion.

Here's an example of setting Chocolatey up with Puppet that sets up and configures Chocolatey, sets up an internal package repository, and shows setting up the licensed edition and ensuring some packages.

  • Download the chocolatey.nupkg from the community repository - download the latest chocolatey nupkg or see Completely offline install to get an older version.
  • Optionally download the chocolatey.server package from the community repository - download the latest chocolatey.server nupkg.
  • Use choco push to push those items to your internal package repository (e.g. choco push chocolatey.0.10.7.nupkg -s http://internal_repo/ -k abc123)
  • Determine how to get the bare url to download the Chocolatey.Nupkg directly. You will need that for the internal url for installing Chocolatey offline. For the community repository, it is https://chocolatey.org/api/v2/package/chocolatey

Chocolatey For Windows Download

Install using PowerShell from cmd.exe

This is the best method if you want to repeat it or include it in source control. It requires no change to your existing PowerShell to allow for remote unsigned scripts.

Create a file named installChocolatey.cmd with the following:

You can also get to this file by going to https://chocolatey.org/installchocolatey.cmd.

If you prefer to have the install.ps1 file already, comment out the download line in the batch file and download the install.ps1 from chocolatey.org and save it as install.ps1 next to the installChocolatey.cmd file.

Run installChocolatey.cmd from an elevated cmd.exe command prompt and it will install the latest version of Chocolatey. You can not run this from powershell.exe without making changes to your execution policy.

NOTE: To create and save a .cmd file, please use a text editor and nothing fancy like Microsoft Word or OneNote.

Install using NuGet Package Manager

When you have Visual Studio 2010+ and the NuGet extension installed (pre-installed on any newer versions of Visual Studio), you can simply type the following three commands and you will have Chocolatey installed on your machine.

Install-Package chocolateyInitialize-ChocolateyUninstall-Package chocolatey

Install using NuGet.exe from PowerShell

You can also use NuGet command line to download Chocolatey:

nuget install chocolatey or nuget install chocolatey -pre

Once you download it, open PowerShell (remote unsigned), navigate to the tools folder and run:

& .chocolateyInstall.ps1

Install downloaded NuGet package from PowerShell

You can also just download and unzip the Chocolatey package (.nupkg is a fancy zip file):

  1. Download the Chocolatey package.
  2. Ensure the downloaded nupkg is not blocked.
  3. Unzip it using any application that supports zip format.
  4. Open a PowerShell command shell and navigate into the unzipped package's tools folder.
  5. NOTE: Ensure PowerShell execution policy is set to at least bypass or remote signed (if you have issues, you may need to set it to Unrestricted).
  6. Call & .chocolateyInstall.ps1 to allow Chocolatey to install.
  7. NOTE: This will not set Chocolatey as an installed package, so it may be a good idea to also call choco upgrade chocolatey -y and let it reinstall the same version, but at least it will be available for upgrades then.

Install licensed edition

Please see installation of licensed edition.

Installing behind a proxy

Have a proxy? Try

  • Cmd.exe:
  • PowerShell.exe (Ensure Get-ExecutionPolicy is at least RemoteSigned):

Installing behind an explicit proxy

See Installing Chocolatey Behind a Proxy Server

Installing to a different location

  1. Create a machine level (user level will also work) environment variable named ChocolateyInstall and set it to the folder you want Chocolatey to install to prior to installation (this environment variable must be set globally or available to PowerShell- it is not enough to simply make it available to your current command prompt session).
  2. Don't use 'C:Chocolatey' unless necessary.
  3. Create the folder manually.
  4. If you have already installed (and want to change the location after the fact):
  • Follow the above steps.
  • Install Chocolatey again.
  • Copy/Move over the items from the old lib/bin directory.
  • Delete your old install directory.

NOTE: There is one really important consideration when installing Chocolatey to a non-default location: Chocolatey only locks down the permissions to Admins when installed to the default location %PROGRAMDATA%Chocolatey, which means the same thing as %SystemDrive%ProgramDataChocolatey.If you are installing to another location, you will need to handle this yourself, i. e. restrict write access to Admins in case you so desire.This is due to alternative locations could have a range of permissions that should not be changed.See Why does Chocolatey install where it does and https://github.com/chocolatey/choco/issues/398 for more details.

Installing a particular version of Chocolatey

Set the following environment variable prior to install:

  • chocolateyVersion - controls what version of Chocolatey is installed

In PowerShell, it looks like this:

NOTE: This will only work with the installation methods that call https://chocolatey.org/install.ps1 as part of the install.

Windows

Use Windows built-in compression instead of downloading 7zip

Set the following environment variable prior to install:

  • chocolateyUseWindowsCompression - this will bypass the download and use of 7zip.

In PowerShell, it looks like this:

NOTE: This will only work with the installation methods that call https://chocolatey.org/install.ps1 as part of the install.

Installing with restricted TLS

NOTE: If your server is restricted to TLS 1.1+, you need to add additional logic to be able to download and install Chocolatey (this is not necessary when running Chocolatey normally as it does this automatically). If this is for organizational use, you should consider hosting the Chocolatey package internally and installing from there. Otherwise, please see this section.

If you see an error that looks similar to the following:

It's possible that you are attempting to install from a server that needs to use TLS 1.1 or TLS 1.2 (has restricted the use of TLS 1.0 and SSL v3), you have some options.

Option 1

If you have the following:

  • PowerShell v3+
  • .NET Framework 4.5

You can just run the following instead of just the one-liner to get Chocolatey installed:

Option 2

You need to download and unzip the Chocolatey package, then call the PowerShell install script from there. See the Download + PowerShell Method section below.

Non-Administrative install

NOTE: This option should be a last resort and is considered to be a more advanced scenario - most things you do on Windows require administrative rights, especially surrounding software management, so you are going to be limited even in packages you attempt to install. If you are using the community package repository, there are over 200 packages you can install from the community repository without administrative permission - see https://chocolatey.org/packages?q=id%3Aportable+tag%3Aportable.

  1. You must choose a different location than the default (see Installing to a different location above). The default is a more secure location that only administrators can update.
  2. Follow that with the command line / PowerShell methods of installation.
  3. Here is an example of this.

NonAdmin.ps1:

If you prefer or need cmd.exe example, please see https://gist.github.com/ferventcoder/78fa6b6f4d6e2b12c89680cbc0daec78

Upgrading Chocolatey

Once installed, Chocolatey can be upgraded in exactly the same way as any other package that has been installed using Chocolatey. Simply use the command to upgrade to the latest stable release of Chocolatey:

Uninstalling Chocolatey

See uninstall.

FAQs

I'm having trouble installing Chocolatey

Make sure you've reviewed More Install Options and looked over Troubleshooting. If you've done those things, reach out over the mailing list or over the chat (Gitter). The links to those can be found in the open source section of https://chocolatey.org/support.

I'm getting a 403 attempting to install

This is addressed in Troubleshooting.

Why isn't there an MSI?

tl;dr - Chocolatey installs as a nupkg like everything else, a PowerShell install script just ensures that.

Chocolatey was born out of providing automation for Windows and doing that with packages, packages that could surround an installer but didn't necessarily need to. The Chocolatey install scripts use the Chocolatey package (a nupkg file itself) to be installed and upgraded as just another package. This means Chocolatey is 'eating its own dogfood' and it is unlikely we'd offer it as an MSI (native installer)as it would fly a bit in the face of what Chocolatey represents (although it is something that we would not rule out).

The installation actually ensures a couple of things:

  • PowerShell is installed and is set up properly.

    PowerShell is a requirement for using Chocolatey, not just for install. It is what drives the package installation process in most cases. Every package can have binaries and/or installation/uninstallation scripts (written in PowerShell). Chocolatey is the framework and each package gets to define how it is installed, upgraded, and uninstalled. It's an extremely flexible framework that has been proven to meet the insanity that is the Windows software installation ecosystem. That flexibility would not be easily achieved without PowerShell.

    We do recognize there are a few organizations that disable PowerShell, so it's very likely in the future our Business Edition will meet that need. PowerShell is a staple of Windows automation, so it is not the norm for an organization in this day and age to disable PowerShell.

    Having an install process that uses PowerShell helps you determine quickly if Chocolatey will be able to be used in your environment.

  • You are open to doing things in a slightly different way, e.g. working with packages as opposed to installers.

    You are open to the concept of using packages. Some folks might say this means we are asking folks to learn to 'do things 'our way' because we know better'. It's less about 'knowing better' and more about learning that Chocolatey does things in a slightly different way. It does that because the world of software is not just installers. Software goes beyond Programs and Features and a system that can track all of that also needs to as well. Package management is not a new concept in the world of software, perhaps just newer to Windows. If folks are not open to that, then they are probably not going to be open to Chocolatey. And that's completely fine. Chocolatey is not for everyone. We may eventually get to more of a masses approach. Right now we are targeting a specific type of audience - those that are looking for better ways to manage software on Windows and open to looking for the best process of doing that.

Windows: The phrase “package manager” sounds a bit ominous, but if you’re smart, you’ve already used one to outfit your Windows PC with all the basics: Ninite. The site couldn’t be any simpler. You pick the programs you want, it creates one installation file for everything, and double-clicking on it installs everything you selected at once.

After that, you’re on your own.

If you want another helping hand to ensure your favorite apps stay updated—or a much larger directory of user-maintained packages (apps) to pick from—consider Chocolatey. No, not the delicious sweet, nor the command line-based app installer. Well. Sort of. The Chocolatey GUI is what you’ll want to check out, because it gives you a lovely graphical interface for installing and managing your apps, which is a lot easier to handle than a lot of command-line typing.

Advertisement

We’ve covered Chocolatey before, but it’s been a while since we talked about it (or the helpful GUI add-on). Here’s a quick refresher on how to get started. First, click on the Start Button in Windows and type in “Command.” When the Command Prompt pulls up in your results, right-click on it and select “Run as administrator.” Then, copy this text, paste it into Command Prompt, and hit Enter.

Once you do, Chocolatey will start installing itself. It doesn’t take very long. When a bunch of text scrolls past and Chocolatey appears finished, type this in and hit Enter:

choco install chocolateygui

More text will go by, and you’ll be prompted to hit “y” at one point to confirm that you want to continue the installation. Once Chocolatey GUI is done installing, your screen should look something like this:

Advertisement

You’ll then be able to pull up Chocolatey GUI by looking for the newly installed program in your Windows start menu. When it loads, you’ll see all the apps you’ve installed on your PC so far (via Chocolately GUI, so, just... Chocolately GUI). To see what else is available, click on “chocolatey” on the left-hand sidebar. And to make everything look prettier, click on the icon in the upper-right that looks like a grid of four windows:

By default, the apps you see are ordered by popularity. Double-click on anything to see a description of what it is, or right-click to pull up a menu where you can start installing an app you’re familiar with. You should be able to “reinstall” apps you already have on your system without mucking anything up. And when you do, or when you install new apps via Chocolatey GUI, they’ll appear in your “This PC” listing. You’ll also be able to see if there are any new available versions of your apps and update accordingly—all with a single click.

Advertisement

Posted on