Using the "choco list" Command in Chocolatey (with examples)
Introduction
Chocolatey is a package manager for Windows that allows users to easily install, upgrade, and uninstall applications and tools from the command line. One of the key commands in Chocolatey is “choco list”, which allows you to display a list of packages available for installation or already installed on your system. In this article, we will explore various use cases of the “choco list” command along with code examples, motivations, explanations, and example outputs.
Use Case 1: Display All Available Packages
To display a list of all available packages that can be installed through Chocolatey, you can simply run the following command:
choco list
Motivation: This use case is particularly useful when you want to explore all the available packages and their versions before deciding which ones to install.
Explanation: The “choco list” command without any additional arguments will list all the available packages from the default Chocolatey package feed.
Example Output:
Chocolatey v0.10.15
7-Zip 19.0.0.20191221074605 [Approved]
7-Zip.CommandLine 19.0.0.20191221074605 [Approved]
7-Zip.install 19.0.0.20191221074605 [Approved]
...
The example output shows a partial list of available packages, including their names, versions, and approval status.
Use Case 2: Display Locally Installed Packages
If you want to view a list of packages that are already installed on your system, you can use the “–local-only” argument with the “choco list” command, like this:
choco list --local-only
Motivation: This use case is beneficial when you need to quickly check which packages you have already installed on your system.
Explanation: The “–local-only” argument limits the output of the “choco list” command to only display packages that are locally installed.
Example Output:
Chocolatey v0.10.15
7-Zip 19.00 [Approved] - Possibly broken
AdobeAcrobatReader 18.9.0 [Approved]
Anaconda3 2020.02 [Approved]
In the example output, you can see a list of locally installed packages, along with their names, versions, approval status, and any additional notes.
Use Case 3: Display a List Including Local Programs
To display a list that includes both Chocolatey packages and locally installed programs, you can use the “–include-programs” argument with the “choco list” command:
choco list --include-programs
Motivation: This use case is useful when you want to have a consolidated view of both Chocolatey packages and other programs installed on your system.
Explanation: The “–include-programs” argument expands the “choco list” command’s output by including programs installed outside of Chocolatey along with the Chocolatey packages.
Example Output:
Chocolatey v0.10.15
7-Zip 19.00 [Approved] - Possibly broken
AdobeAcrobatReader 18.9.0 [Approved]
Anaconda3 2020.02 [Approved]
Google Chrome 83.0.4103.97 [Installed]
The example output demonstrates a mixed list of both Chocolatey packages and locally installed programs, providing a comprehensive overview of software installed on the system.
Use Case 4: Display Only Approved Packages
If you are interested in seeing a list of only approved packages, you can use the “–approved-only” argument with the “choco list” command:
choco list --approved-only
Motivation: This use case is helpful when you want to view a subset of packages that have been verified and approved by the Chocolatey moderation team.
Explanation: The “–approved-only” argument filters the output of the “choco list” command to display only approved packages.
Example Output:
Chocolatey v0.10.15
7-Zip 19.0.0.20191221074605 [Approved]
7-Zip.CommandLine 19.0.0.20191221074605 [Approved]
7-Zip.install 19.0.0.20191221074605 [Approved]
...
The example output illustrates a list of approved packages, showing their names, versions, and approval status.
Use Case 5: Specify a Custom Source to Display Packages From
If you want to display packages from a specific source other than the default Chocolatey feed, you can use the “–source” argument followed by the source URL or alias:
choco list --source source_url|alias
Motivation: This use case is useful when you need to view packages from a custom package feed or a different Chocolatey repository.
Explanation: By using the “–source” argument, you can provide a custom source URL or alias to fetch packages from. This allows you to display packages from a different feed than the default Chocolatey package repository.
Example Output:
Chocolatey v0.10.15
7-Zip 19.0.0.20191221074605 [Approved]
...
The example output shows a list of packages retrieved from the specified custom source, indicating their names, versions, and approval status.
Use Case 6: Provide Username and Password for Authentication
If your custom package source requires authentication, you can provide a username and password using the “–user” and “–password” arguments with the “choco list” command:
choco list --user username --password password
Motivation: This use case is necessary when you want to authenticate yourself to a custom package feed that requires credentials.
Explanation: The “–user” and “–password” arguments allow you to specify a username and password to authenticate yourself when accessing the custom package source. This ensures that you can view the packages from a secure repository that requires authentication.
Example Output:
Chocolatey v0.10.15
7-Zip 19.0.0.20191221074605 [Approved]
...
The example output demonstrates a list of packages retrieved from the custom package source after successful authentication, displaying their names, versions, and approval status.
Conclusion
The “choco list” command in Chocolatey is a versatile tool that allows you to explore and manage packages efficiently. In this article, we covered various use cases of the “choco list” command, including displaying available packages, locally installed packages, programs, approved packages, specifying custom sources, and providing authentication credentials. These examples should give you a good understanding of the different ways you can utilize the “choco list” command for package management in Chocolatey.