12

How does Chocolatey determine which packages are installed on the local system?

Somehow choco list -localonly lists packages installed locally and invokes nuget.exe in the process. In NuGet I know packages.config lists installed packages, but in Chocolatey I don't seem to find a similar file.

Anthony Mastrean
  • 20,318
  • 20
  • 92
  • 173
Christian
  • 9,205
  • 6
  • 42
  • 51

1 Answers1

16

choco list -lo only lists the latest versions of the packages you have installed.

Old choco invoked nuget.exe, new choco (0.9.9+) does it directly since it has nuget.core built-in.

It does a list against %ChocolateyInstall%\lib when you call list -lo. If several versions of the same package exist, only the latest version will be listed. Use list -lo -a to show all versions of the same package available locally.

Further, it is not based on folders, but on the actual nupkg files in those folders.

If you want a list of programs and features, add -i as an option. See choco list -h or the docs page for details.

ferventcoder
  • 10,640
  • 2
  • 51
  • 83
  • Thanks @ferventcoder! In my lib dir is much more than what is just listed in list -lo. How does choco really determine what's installed and what's just and old version lying around? – Christian Jun 19 '15 at 14:57
  • @Christian So chocolatey loads up nuget's package manager and points to the local directory. It looks at the nuget packages that are there at the latest versions. It's not a simple folder based scan to see what is installed. To see all the old versions as well you should look at `choco list -h` to get the all versions option to use with `choco list -lo`. – ferventcoder Jun 19 '15 at 17:07
  • @Christian I don't understand this: "and what's just and old version lying around?" What do you mean by that? – ferventcoder Jun 19 '15 at 17:08
  • What I meant was: If I enter `choco list -lo` I get as output for example `putty 0.64`, whereas choco's lib directory and `choco list -lo -AllVersions` show `putty 0.63` AND `putty 0.64`. I was trying to determine the logic that choco uses to determine what's installed and what's not, i.e. trying to understand the logic why it only shows `putty 0.64` (the latest version). Now I understand that it does not determine what's installed when running `choco list -lo`, but simply shows the latest version number. Thank you! – Christian Jun 22 '15 at 08:48
  • I have edited the answer to reflect my current understanding: `list -lo` does not list *installed* packages as I thought, it lists the latest version of the *locally available* pacakges. The following question remains: Is there a way to list locally *installed* packages? – Christian Jun 22 '15 at 09:17
  • Not quite right. I updated the edit. Perhaps you are using the term "package" and you mean to state "software" as in what is installed in programs and features? – ferventcoder Jun 22 '15 at 15:41
  • Installed packages of software through choco will be in the `choco list -lo` - and if you need all versions and prereleases you should adjust your query accordingly `choco list -lo -pre -all`. – ferventcoder Jun 22 '15 at 15:43
  • OK, many thanks for clarifying! Yes, I mean *installed software* as in programs and features. – Christian Jun 23 '15 at 10:55
  • I will update the comment for how you can include the programs and features list – ferventcoder Jun 23 '15 at 13:34
  • @Christian there is a way to get to the ARP (programs and features) list as well. I'd suggest using the help menus in choco. They are actually quite good now. `choco list -h` – ferventcoder Jun 23 '15 at 16:33