# Add vs dev at a local path

**URL:** <https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150>\
**Category:** New to Julia\
**Tags:** package, development\
**Created:** [March 29, 2021, 7:55am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150 "2021-03-29T07:55:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![erans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erans/32/22032_2.png) [@erans](https://discourse.julialang.org/u/erans)\
**Post date:** [March 29, 2021, 7:55am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/1 "2021-03-29T07:55:20Z")

</div>

Hello all,

I’m still a bit confused about the difference between adding and developing a package _at a local path_.  
so:

```julia
(@v1.4) pkg> add <path>/<to>/<my>/<package>

```

versus

```julia
(@v1.4) pkg> dev <path>/<to>/<my>/<package>

```

I’ve read the [part of the Pkg documentation](https://pkgdocs.julialang.org/v1/managing-packages/#Adding-a-local-package) that states:

> Note tracking a package through `add` is distinct from `develop` : changes to files in the local package repository will not immediately be reflected when loading that package. The changes would have to be committed and the packages updated in order to pull in the changes.

but I don’t understand what that means.

Say I `]add <path>/<to>/<my>/<package>` and at that point in time the `experiment` branch of my repository is active.  
I’m now tired of working on this `experiment` and switch back to `main`.

What is julia actually tracking? and what will be reflected when I `import MyPackage`?  
I take it that the changes should _not_ be directly reflected, but that seems highly unintuitiv if the package is _at a path_.

Thank you for the clarification,  
Eran

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [March 29, 2021, 8:21am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/2 "2021-03-29T08:21:46Z")

</div>

If you `dev` the path it will load whatever code is at the path at the load time.

If you `add` the path it will ask `git` for a snapshot of the commited code in your working copy at the add time and store that among your packages. Then it will keep loading that snapshot.

---

<div class="post-metadata">

**Author:** ![erans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erans/32/22032_2.png) [@erans](https://discourse.julialang.org/u/erans)\
**Post date:** [March 29, 2021, 8:52am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/3 "2021-03-29T08:52:49Z")

</div>

Thanks,  
So that means that in my example, because the `experiment` branch was active at `add`-time that will be the snapshot that is stored.  
If I want the `main` branch stored I have to make sure to first activate it.

**follow-up** :  
In that case, is it possible to `add` multiple versions of the same package by first activating different commits (for example version tags)?  
The documentation mentions how we can switch between different branches and the registry version, but is it actually possible to have several versions active simultaneously in one environment?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [March 29, 2021, 9:10am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/4 "2021-03-29T09:10:56Z")

</div>

> [@erans](#):
>
> but is it actually possible to have several versions active simultaneously in one environment?

No. (Well, if you change uuid and name between your branches you can have them in the same environment and load them at the same time but then they are actually different packages and not different versions.)

---

<div class="post-metadata">

**Author:** ![erans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erans/32/22032_2.png) [@erans](https://discourse.julialang.org/u/erans)\
**Post date:** [March 29, 2021, 9:20am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/5 "2021-03-29T09:20:57Z")

</div>

So that means that in this situation I would have to:

- remove the package `] rm MyPackage`
- Change to whatever branch, commit etc. at the package path
- re-add the package `] add <path>/<to>/<package>`  
correct?

Or does simply calling `] add <path>/<to>/<package>` suffice to “overwrite” it?

(It doesn’t seem like using `free` is really an option here, since the package is not in a registry)

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [March 29, 2021, 9:37am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/6 "2021-03-29T09:37:30Z")

</div>

Anytime you `add` or `dev` a package it will just replace whatever specification of the package you had previously. You also have the option of doing things like `add path/to/package#master` to choose a specific branch. It is easy to inspect what happens by reading the package entry in `Manifest.toml` in your environment.

---

<div class="post-metadata">

**Author:** ![erans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erans/32/22032_2.png) [@erans](https://discourse.julialang.org/u/erans)\
**Post date:** [March 29, 2021, 9:40am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/7 "2021-03-29T09:40:04Z")

</div>

Great, thank you for all the answers 🙏

---

<div class="post-metadata">

**Author:** ![orome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orome/32/26965_2.png) [@orome](https://discourse.julialang.org/u/orome)\
**Post date:** [July 12, 2021, 1:40pm UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/8 "2021-07-12T13:40:45Z")

</div>

Great answer. This makes sound pretty simple, and blows through a lot of what’s confused me about how it works.

If I’ve got this right, `dev` is simply a substitute for `add` that uses the current contents of the specified directory rather than a snapshot in the package registry.

But if that’s right, [I’m still a bit confused](https://www.reddit.com/r/Julia/comments/oicxix/confused_about_how_dev_works/h4x36fu?utm_source=share&utm_medium=web2x&context=3) about the often recommended use of `dev <hosted get repo>` and all the discussion around storage of packages under development in `~/.julia/dev/` (including activating there).

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [July 12, 2021, 2:03pm UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/9 "2021-07-12T14:03:46Z")

</div>

`dev` of a URL does a bit more than `dev` of a path and is basically a convenient way to have Julia make a clone of the code followed by `dev` of the path to the clone. If you already have a clone of the package you can just `dev` its path directly, in particular if you prefer it to be placed somewhere other than where Julia clones it. `dev` of a registered package name provides the additional service that Julia looks up the package URL in the registry for you but is otherwise the same as `dev` by URL.

Working with an activated package is frequently a better option than having it `dev`ed to your default environment but is not a general replacement for `dev`. E.g. you might be working on activated package `A` which depends on package `B`. If you also need to make local changes to `B` you would `dev` it from the environment of `A`. (Or you could `dev` both packages from an outside environment.)

---

<div class="post-metadata">

**Author:** ![orome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orome/32/26965_2.png) [@orome](https://discourse.julialang.org/u/orome)\
**Post date:** [July 12, 2021, 2:40pm UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/10 "2021-07-12T14:40:00Z")

</div>

Excellent, that makes sense! So as long as I’m the only developer and am working locally, activating the package serves my purpose with `dev` giving the additional ability to use the same code in arbitrary places and with (potentially) other packages under development.

And where `dev`’s power really comes into play is for collaboration (via a git remote)?

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [October 20, 2021, 11:19am UTC](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150/11 "2021-10-20T11:19:44Z")

</div>

> [@GunnarFarneback](#):
>
> If you `add` the path it will ask `git` for a snapshot of the commited code in your working copy at the add time and store that among your packages. Then it will keep loading that snapshot.

In this case, if you `update` the package, it will re-check the original path, recover an snapshot of any new commits, and use that, right?
