How to see all installed packages? + a few other `Pkg` related questions


#1
  1. I have more than a hundred packages installed. But Pkg.installed() only lists some 40 due to the size of the terminal window. How can I see all installed packages?

  2. Also, how can I have the installed packages printed alphabetically using Pkg.installed()? It’s hard to pick ham from peas.

  3. It takes more than 5 minutes on my machine for Pkg.installed() to return. Is this normal?

  4. Is there a way to see all registered Julia packages on the METADATA git page: https://github.com/JuliaLang/METADATA.jl. The last 277 packages are not see-able on that page.

  5. I use a package which is registered with METADATA. But I don’t use its tagged version, since it’s too old. I use the development version that I checked out from its git repo. However, each time when I Pkg.update(), the tagged version is installed automatically and overrides the version I intend to use. This really drive me nuts as I have to manually Pkg.rm the tagged version. Is there a way to avoid this?

Sorry to be lengthy. Thanks!!


#2

I’ll try and answer these questions, though I’m no expert.

  • Pkg.installed() returns a Dict, so you could pass it to the sort function and also write a loop to see the list a few lines at a time, or just list all the keys in alphabetical order

    showall(sort(collect(keys(Pkg.installed()))))

  • It will probably be O(n) on the number of packages since it’s a file-system operation to look through all packages on disk

  • git clone https://github.com/JuliaLang/METADATA.jl and then view the file locally. The limitation on what you see on the github page is imposed by github.

  • Try Pkg.pin to pin the package to the version you want, or Pkg.checkout to always stay on the latest version.


#3

sort(collect(Pkg.installed())) will print them in sorted order. show(STDOUT, "text/plain", sort(collect(Pkg.installed()))) will print them all, but it would be nice to have something better by default.

Are you using Windows? Julia’s package system currently uses lots of little files in the METADATA repo to store metadata, which is pretty slow on Windows (it was even worse before we switched to libgit in Julia 0.5). At some point we are hoping to switch to a new package metadata system that will eliminate this problem (https://github.com/JuliaLang/Juleps/blob/master/Pkg3.md).

Normally I would recommend looking at the listing at http://pkg.julialang.org/

To see the github listing directly you may have to clone the repo, or do print(readdir(Pkg.dir("METADATA"))) in Julia.

Normally if you do Pkg.checkout("somepackage"), then update() will stay on the master release. Is that not working?


#4

A faster way to access the installed packages can be to read all directories in Pkg.dir()

readdir(Pkg.dir())

Please note that there are some extra directories in it (like .cache, .trash, and METADATA). If you want to print them all alphabetically:

 println.(readdir(Pkg.dir()));

http://pkg.julialang.org/


#5

Thanks!

I’m inclined not to clone the repo. I think @stevengj’s method works better for me.

Thanks for the tip!


#6

Yes. It’ll be more convenient if something like show(STDOUT, "text/plain", sort(collect(Pkg.installed()))) can be set as default or at least be able to be opt for.

No. I’m on Ubuntu. I think it’s more or less because my machine is old and was running something else at the same time, though it’s definitely on the scale of minutes rather than seconds.

This works perfectly.

Thanks for the tip!


#7

Yes, it’s indeed quicker than Pkg.installed(), as I usually don’t care much about the version tags. Thanks!


#9

Pkg.dir() only lists the first package directory. This doesn’t work if you have multiple package directories.


#10

Thanks for pointing out. I wasn’t aware of this.