# Updating environments

**URL:** <https://discourse.julialang.org/t/updating-environments/28274>\
**Category:** General Usage\
**Tags:** package-manager\
**Created:** [September 2, 2019, 1:06am UTC](https://discourse.julialang.org/t/updating-environments/28274 "2019-09-02T01:06:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bernardofpc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernardofpc/32/7783_2.png) [@bernardofpc](https://discourse.julialang.org/u/bernardofpc)\
**Post date:** [September 2, 2019, 1:06am UTC](https://discourse.julialang.org/t/updating-environments/28274/1 "2019-09-02T01:06:00Z")

</div>

I have written some Julia packages that depend on each other. To make it simple, suppose `A.jl` depends on `B.jl`. I have added `B` to my `Project.toml` and `Manifest.toml` files, and both packages (must) live on a private Git repository. Now, I have updated `B`, and on my dev host I have updated `A`’s environment so that it now contains the appropriate `git-tree-sha1` and `repo-rev` for it. What command can I issue on the production host (after updating git) that would trigger the fetching and updating of B on the host environment?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 2, 2019, 11:25am UTC](https://discourse.julialang.org/t/updating-environments/28274/2 "2019-09-02T11:25:23Z")

</div>

As I understand it, the answer is `Pkg.rm` followed by `Pkg.add` (see [How to activate a package in a script? - #19 by fredrikekre](https://discourse.julialang.org/t/how-to-activate-a-package-in-a-script/28185/19)).

However, I find it easier to roll my own package registry. Then I just need to make a blank environment on the remote and issue `Pkg.add(A)`.

---

<div class="post-metadata">

**Author:** ![bernardofpc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernardofpc/32/7783_2.png) [@bernardofpc](https://discourse.julialang.org/u/bernardofpc)\
**Post date:** [September 2, 2019, 9:30pm UTC](https://discourse.julialang.org/t/updating-environments/28274/3 "2019-09-02T21:30:39Z")

</div>

> [@hendri54](#):
>
> As I understand it, the answer is `Pkg.rm` followed by `Pkg.add` (see [How to activate a package in a script?](https://discourse.julialang.org/t/how-to-activate-a-package-in-a-script/28185/19)).

I didn’t quite get it. Should I `rm/add` package `A` or package `B`? Since `B` is already installed, would it be updated upon re-adding `A`? Is this clearly documented somewhere?

Also, I’d rather not have an “install” script for my code, and rely on `Pkg`’s ability to resolve dependencies, because if somehow `B` now depends on `C`, then `A` would have to know that as well. It was probably not clear from my first message, but I want a **precise** commit for `B` (for reproducibility, among other things), so “the most recent” doesn’t work.

> [@hendri54](#):
>
> However, I find it easier to roll my own package registry. Then I just need to make a blank environment on the remote and issue `Pkg.add(A)` .

I’ll look into that, it seemed overkill a while ago, but maybe it’s the right thing here. Also, for the rest of our devs (and my 2 other computers…), I’d prefer not to need to reinstall everything on a new environment each time our packages update, but just something along the lines of (I’d might have gotten it wrong)

```bash
$ git fetch
$ git rebase
$ julia --project=. "using Pkg; Pkg.update()"

```

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 3, 2019, 2:08pm UTC](https://discourse.julialang.org/t/updating-environments/28274/4 "2019-09-03T14:08:36Z")

</div>

It’s complicated… and not really documented anywhere as far as I can tell.

As for making a registry, see [Creating a custom registry](https://discourse.julialang.org/t/creating-a-custom-registry/28007). This worked for me.

For unregistered dependencies, `Pkg` cannot track the chain of dependencies (this is [issue 810](https://github.com/JuliaLang/Pkg.jl/issues/810)). So you need to add unregistered dependencies “by hand” in the right order. For example, if A depends on B depends on C, you need to add C first, then B.

If you want to add a package with a specific commit (rather than the latest), I believe you can specify the the git sha in the `PackageSpec` and then use `add` (I have not tested this, though). But you would still have an install script - I don’t see a way around this without a registry.

But please take what I am saying with more than a grain of salt. I’m not an expert, which is why I pointed you to the “How to activate” thread where more knowledgeable people chimed in.

PS: In case it’s useful, I write up what I have figured out [here](https://lhendricks.org/julia_notes.pdf) (precisely b/c I have trouble finding documentation on workflow issues and also following the various threads on discourse. Perhaps useful.
