Is it possible upgrade all environments present in a machine at once? That is, instead of going project by project to upgrade packages, can I do that with a (few) commands?
On Unix systems you could presumably run the shell command
find . -name "Project.toml" on your filesystem and pipe the results through a
Pkg.activate(dir); Pkg.update() loop. But that’s a little scary unless you’ve been absolutely faithful about adding exhaustive
[compat] declarations to all your
Project.toml files. Much of the point of environments is that the Manifest records a known-working set of packages, and this will throw that away without verifying that your code in that project still works.
So, no Julia built in command? Doesn’t Julia keep track of all environments so that when one does
Pkg.gc() it doesn’t delete versions of packages used in other environments?
You can get a list of Active Manifests by using the verbose argument of
gc command ( eg
]gc -v or
Pkg.gc(verbose=true). Then by substituting Project to Manifest in the list you get all active Projects (but check that such instances are in your own directories, not in Julia ones such as
I have done such a bash script for Linux/Cygwin, and use it for info purposes - see
I did not generalized it to auto-update, it should be easy, but it is really a good idea, I doubt it. Others, any comments about the idea?
You can find the manifests that Julia knows about in
~/.julia/logs/manifest_usage.toml. From there you could write some code to parse that TOML file, activate each environment and do
Pkg.up in it. Probably about 10 lines of code altogether. I’m not entirely clear why it would be a good idea to do this though.
This would do it (please only try if you actually want to update all your environments to the latest versions of all packages):
using Pkg, TOML for manifest in keys(TOML.parsefile(joinpath(DEPOT_PATH, "logs", "manifest_usage.toml"))) Pkg.activate(dirname(manifest)) Pkg.update() end
For the record, to update all environments to the latest version of a single package, replace
I would also add the following line
if occursin(r"\.julia.packages",manifest); @info "Skipping installed package $manifest"; continue; end
just before the
activate in order to skip the registered/installed packages update, just to be sure …
My 2 cents.