# Upgrade all environments

**URL:** https://discourse.julialang.org/t/upgrade-all-environments/67903
**Category:** Package Management
**Created:** [September 9, 2021, 1:50am UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903 "2021-09-09T01:50:27Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [September 9, 2021, 1:50am UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/1 "2021-09-09T01:50:27Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [September 9, 2021, 8:43am UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/2 "2021-09-09T08:43:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [September 9, 2021, 8:49am UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/3 "2021-09-09T08:49:07Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)
#### Post date: [September 9, 2021, 4:36pm UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/4 "2021-09-09T16:36:26Z")

</div>

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 `packages`, …).

I have done such a bash script for Linux/Cygwin, and use it for info purposes - see `julia-listp` in  
[https://github.com/jdadavid/juliashellutils.git](https://github.com/jdadavid/juliashellutils.git)

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?

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [September 9, 2021, 7:44pm UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/5 "2021-09-09T19:44:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [September 9, 2021, 8:47pm UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/6 "2021-09-09T20:47:40Z")

</div>

This would do it (please only try if you actually want to update all your environments to the latest versions of all packages):

```julia
using Pkg, TOML

for manifest in keys(TOML.parsefile(joinpath(DEPOT_PATH[1], "logs", "manifest_usage.toml")))
    Pkg.activate(dirname(manifest))
    Pkg.update()
end

```

---

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [September 9, 2021, 9:20pm UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/7 "2021-09-09T21:20:42Z")

</div>

Great thanks!  
For the record, to update all environments to the latest version of a single package, replace `Pkg.update()` with `Pkg.update("Example")`.

---

<div class="post-metadata">

### Author: ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)
#### Post date: [September 10, 2021, 9:08am UTC](https://discourse.julialang.org/t/upgrade-all-environments/67903/8 "2021-09-10T09:08:42Z")

</div>

I would also add the following line

```julia
	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.
