# Packages under /.julia/dev/ shared by different versions of Julia?

**URL:** https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537
**Category:** General Usage
**Tags:** question
**Created:** [July 4, 2020, 9:06pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537 "2020-07-04T21:06:45Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Ken\_Lin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_lin/32/14367_2.png) [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)
#### Post date: [July 4, 2020, 9:06pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/1 "2020-07-04T21:06:46Z")

</div>

Hello,

Packages installed for different versions of Julia on my computer should be independent from each other, right?  
For example, I can have JuMP 0.18 installed for Julia 1.3.1 while having JuMP 0.21 installed for Julia 1.1.1  
Now I have version 0 of a package (called it “A”) cloned from github on Julia 1.3.1, and I tried to clone version 1 of this package A on Julia 1.1.1. But when I did “using A” on Julia 1.1.1, it loaded version 0 (which is only installed for my Julia 1.3.1) instead of version 1.  
This package seems to locate under “/.julia/dev/”. I can’t see this directory is separated by different Julia versions. Is this a directory shared by all versions of Julia on my computer? And how can I have different versions of package A for different versions of Julia?

Thank you!

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 4, 2020, 9:57pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/2 "2020-07-04T21:57:35Z")

</div>

You can have many versions of a package installed and shared between Julia versions, either in the standard way (the code of those versions can be found in `.julia/packages`, but users normally don’t have to take care of that), or in “development mode” (by default in `.julia/dev`, but you can choose any folder, so you can have even different development versions at the same time).

The version that will be used when you do `using A` is defined in the `Manifest.toml` file of the environment you are using. The default environment for each version of Julia can be found in `.julia/environments/`.

Look for the entry for your package in the corresponding `Manifest.toml`. If it has a `path` entry, you will be using the source code present in that path as development version. If instead it has a `git-tree-sha1` entry, it means that you will be using a version added in the standard way.

The commands `]add`, `]dev`, `]free`, etc. always operate on the environment that you have activated at the time of calling them.

---

<div class="post-metadata">

### Author: ![Ken\_Lin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_lin/32/14367_2.png) [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)
#### Post date: [July 5, 2020, 1:29am UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/3 "2020-07-05T01:29:36Z")

</div>

Thank you! I see package A in Manifest.toml of Julia 1.1.1 has a path entry. How can I change this so that it will use the version I cloned from github? Should I manually edit this Manifest.toml file? Now I only see version 0 of package A under .julia/dev, which is being used by all Julia versions. My goal is to install version 1 of A, and use it on Julia 1.1.1, while keep using version 0 on Julia 1.3.1. How can I achieve this?

Also, why was package A added to the .julia/dev while the other packages were added to .julia/packages? I don’t think I have been asked where to install the packages.

Thank you!

---

<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: [July 5, 2020, 1:59am UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/4 "2020-07-05T01:59:41Z")

</div>

Which version of a package is used does not depend on the Julia version per se but on the active environment.  
When you start Julia 1.1 you are in environment `v.1.1`. When you issue `Pkg.add`, you effectively edit the Project.toml of `v.1.1`. If you switch to a different folder and `Pkg.activate(".")` you edit that folder’s Project.toml from then on.  
`Pkg.add` looks up the package in the registry, writes it into Project.toml (for the currently active environment) and fetches the version that you specify in the `add` command (usually the latest) into `.julia/packages`. That location can have many versions of a package at the same time.  
`Pkg.dev` does the same, but downloads to `.julia/dev`. There you can edit the code and changes will be known to Julia without downloading anything. The Project.toml entry points to `.julia/dev` (or wherever you put the package) and Julia does not consider the registry for that package any more.  
You never edit Manifest.toml. It is auto generated by resolving dependencies through Pkg.  
If you want Julia 1.1 to use the version of `A` that you downloaded to `.julia/dev`, you `Pkg.develop A` in `v.1.1` (the environment).  
To use a current registered version of `A` in 1.3.1, you `Pkg.add A` while in that environment.

---

<div class="post-metadata">

### Author: ![Ken\_Lin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_lin/32/14367_2.png) [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)
#### Post date: [July 5, 2020, 2:52am UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/5 "2020-07-05T02:52:22Z")

</div>

Thank you! As you suggested, by using `Pkg.add A`, I’m now able to use the current version of `A`.  
Previously I downloaded `A` by `Pkg.clone`. Is that the reason that it went to `.julia/dev` instead of `.julia/packages`? Even if I do `Pkg.clone("A")` now, `.julia/dev` still only has the old version of `A` . Why is the current version not cloned to `.julia/dev`? Can it not have both the current version and the old version?

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 5, 2020, 7:47am UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/6 "2020-07-05T07:47:08Z")

</div>

I think that `Pkg.clone` is not meant to be used directly. Use only the commands explained here: [Pkg · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Pkg)

To clone a package for development use `Pkg.develop` or `]dev`. However, as you say, if the `.julia/dev/A` already exists, this will track that version, instead of downloading a newer one.

This is because if you are developing the package, you are meant to control the changes of the code on your own. If there is a newer version you want to clone, you should do it via git directly (`git pull`, etc.), and then you can switch between different versions with `git checkout`.

---

<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: [July 6, 2020, 4:08pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/7 "2020-07-06T16:08:41Z")

</div>

Are you actually intending to edit the code in the cloned version of the package? Or are you just trying to have two different versions of `A` as dependencies for two different versions of Julia?

If the latter, don’t `develop A`; instead `Pkg.add` the version that you want to pin for the older Julia version.

Note also that you can always download a new version of `A` to anywhere you want using any method you want. If you then `develop(path/toA)` you will use that version of `A` in that particular environment. `develop` just means: put an entry into `Package.toml` that points to a local folder. Whatever code sits there will be used in that environment. That could be your own code or a package that you downloaded (by whatever method) from anywhere else.

---

<div class="post-metadata">

### Author: ![Ken\_Lin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_lin/32/14367_2.png) [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)
#### Post date: [July 8, 2020, 3:01pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/8 "2020-07-08T15:01:33Z")

</div>

Thank you! If my understanding is correct, `Pkg.add("A")` or `Pkg.add(PackageSpec(url="url of A"))` will always update the package `A` to its most recent version for my current environment, while I can have another `version 2` of `A` stored at some `path` on my computer, and I can always switch back to `version 2` by doing `Pkg.develop(PackageSpec(path="path to version 2"))`. These are true for all packages, both unregistered packages and registered packages. Is this correct?

---

<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: [July 8, 2020, 3:26pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/9 "2020-07-08T15:26:32Z")

</div>

Yes, but you don’t have to `develop` a package just to get a specific version. You can add a version specification to `add` instead.

If you don’t plan to edit the code, just use `add`.

And to ensure that the package does not get updated, you can `pin` it. The `Pkg` docs have the syntax for this.

---

<div class="post-metadata">

### Author: ![Ken\_Lin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_lin/32/14367_2.png) [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)
#### Post date: [July 8, 2020, 3:37pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/10 "2020-07-08T15:37:59Z")

</div>

Thank you! Does `add` a specific version work for packages that don’t have a version number? For example, I want to have an older version of a package which can only be installed using url from github, but the one on github only has the code for the most recent version. Doing `add url` will only give me the most recent version, right? I do have the older version stored under my `.julia/dev`, that’s why I’m thinking of using `develop` to go back to that older version. I’m not sure if `add` will also work in this case?

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 8, 2020, 4:29pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/11 "2020-07-08T16:29:25Z")

</div>

`add A#master` to use the master branch (or choose any other branch or commit sha).  
[https://julialang.github.io/Pkg.jl/v1/managing-packages/](https://julialang.github.io/Pkg.jl/v1/managing-packages/)

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [July 8, 2020, 5:03pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/12 "2020-07-08T17:03:47Z")

</div>

What i do is this.

1. Create a `.julia\environments\tomls` dir with the `Manifest.toml` and `Project.toml` files
2. For each Julia version make symbolic links to that dir under `.julia\environments` … `v1.4`, `v1.5`, etc

Now no need the annoying reinstall of all packages for each julia version.

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 8, 2020, 8:45pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/13 "2020-07-08T20:45:24Z")

</div>

I don’t recommend this: say you update some package to a version that requires Julia 1.4 (or any other minor version); then your environment for lower versions will be broken.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [July 8, 2020, 10:17pm UTC](https://discourse.julialang.org/t/packages-under-julia-dev-shared-by-different-versions-of-julia/42537/14 "2020-07-08T22:17:53Z")

</div>

That is true, but for many people that situation does not apply and, besides the annoyance when installing more than one Julia version, avoiding duplicating GB of packages is also worthwhile to some.
