# Understanding environments and projects

**URL:** <https://discourse.julialang.org/t/understanding-environments-and-projects/25741>\
**Category:** General Usage\
**Created:** [June 26, 2019, 6:55pm UTC](https://discourse.julialang.org/t/understanding-environments-and-projects/25741 "2019-06-26T18:55:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [June 26, 2019, 6:55pm UTC](https://discourse.julialang.org/t/understanding-environments-and-projects/25741/1 "2019-06-26T18:55:51Z")

</div>

I have a few questions about environments and projects in julia’s package manager. I have read the documentation, so these questions are really about making sure I understand properly.

Q1. In `.julia/environments` lists all the environments that Julia sees. As of right now, I see a folder called `v0.7` and `v1.0`, each with a `Manifest.toml` and `Project.toml` files. What this tells me is that in the default environment of `v1.0`, the `Project.toml` files tells me what packages are available for me to use. I can edit this file using `add`, `up`, `rm` from the package manager.

Q2. I also see a folder called `.julia/packages`. Here I see all the packages I’ve added previously (as well as their dependencies. In each package folder, there are subfolders each containing a full copy of the source. I assume these subfolders are packages at some state (given by the `git` hash). This makes perfect sense since different projects may depend on different versions of a package. Is my understanding correct? (There might be way more packages in this folder than in `Project.toml`… some of these are dependencies of the packages themselves, some of them do nothing and would be deleted once I run garbage collector, correct?)

It’s time to write my own package, so I do `generate FooBar` which will create a folder with a `Manifest.toml` and a `Project.toml` file, as well as a source folder with a barebones module. I can `cd` into this directory and type in `activate .` which changes my environment from default `v1.0` to `FooBar`. Here lies my confusion.

Q3. I can add a dependency by saying `add Example` which adds the project at its latest release (in github). This edits the `Project.toml` file as well as downloads a copy to `.julia/packages` (it dosn’t redownload if it’s already there), correct?

Q4. However, why do I have to `add`? If I just type in `using Example`, it works… I am a little confused here. Since I never `add` the package, how can I run `using Example`? What version does it use? I suppose if I want to share my package with others, I should `add` first to force the end user to download the package… otherwise they may have the wrong version or might not even have the package at all.

Q5. Why dosn’t the `.julia/environments` update itself? I’ve added a new environment called `FooBar` (which is in some other directory) but I would like to have all my environments in one folder… I am not sure if this makes sense.

Q6. At no point did I ever run `dev`? What is the purpose of that? I am already “developing” my package so do I need to run `dev`?

Q7. What is the correct way to contribute to Julia/packages? Right now, my work flow is simply to `git clone` the project, stay in my `v1.0` environment, download the packages I need, and submit PR if required. I’ve seen people using `dev` for an alternative workflow.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [June 26, 2019, 8:21pm UTC](https://discourse.julialang.org/t/understanding-environments-and-projects/25741/2 "2019-06-26T20:21:25Z")

</div>

Q1: Yes  
Q2: Yes  
Q3: Yes  
Q4: Environments are stacked, if you look at e.g. `Base.load_path()` after you activate your new package you see that there are multiple entries there. When you do `using Example` Julia finds it in the second entry in the stack – the default environment v1. However, since you have not `add`ed the Example package to the new environment you can not `using Example` from within that package itself.  
Q5: Not sure what you mean, why would you want all projects in that folder? Instead you keep each toml-pair in your project folder.  
Q6: `dev` is convenience for `git clone url.to.pacakge && dev path/to/git-repo`. For example, if you want to be able to `using Foobar` from your default environment you can add it to that environment by `dev`ing the path to your generated package.  
Q7: Easiest is either to use `dev` as described above, or you can just manually git clone it and work within that package environment. You should never have to download any packages yourself though.
