Search code examples
installationchocolatey

I cannot install packages with Chocolatey


When I write the command choco install 'Name' This is what happened:

'Name' not installed. The package was not found with the source(s) listed. Source(s): 'https://chocolatey.org/api/v2/' NOTE: When you specify explicit sources, it overrides default sources. If the package version is a prerelease and you didn't specify --pre, the package may not be found. Please see https://chocolatey.org/docs/troubleshooting for more assistance.


Solution

  • Most likely, it's because you're doing this from the Command Prompt, and wrapping the package name in single-quotes. Remove the single quotes and it should work. If this doesn't work or you are using PowerShell as your CLI, then read on for some config troubleshooting steps.


    Check that the package exists in one of your configured repos:

    Example has been updated as choco list and choco search are no longer synonyms as of Chocolatey 2.x.

    choco search packageName
    

    where packageName is the name of the package you want to install. If you get a response, double check the package name is correct for what you passed to choco list; sometimes the package name might be different but still be tagged for the search term you used.

    If you don't get any hits, double check the online portal that the package actually exists. Not everything has a Chocolatey package, they are often maintained by third-party volunteers. If you find the package here, try installing it with the command they give you (the package information page will include a copy/pastable installation command).

    If it still doesn't work but you've confirmed the package exists, make sure that you have the public repo configured (or internal repo if this is a non-public package, but obviously I won't have that URL here):

    choco sources
    

    This should list all repos configured on your system. Assuming you're looking for a public package, you should see a chocolatey repository returned similar to the following (the URL is what's important here):

    chocolatey - https://chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.
    

    If the public repo doesn't show here, or you see [Disabled] following the repo name, fix it like so:

    1. If disabled:

        # If the repo is not named chocolatey, use the repo name returned by the choco sources command
        choco source enable -n chocolatey
      
    2. If not present at all:

        choco source add -n chocolatey -s 'https://chocolatey.org/api/v2/'
      

    If none of this works, the problem is likely networking or otherwise infrastructure related. One of the weaknesses of relying on the public repo is that it is known to go offline during US off-hours periodically. This is why we don't rely on the public repo at work and either squid-proxy the ones we need or maintain our own packages in our own private feed.