# Workflow for forking an environment

**URL:** <https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660>\
**Category:** General Usage\
**Created:** [January 27, 2023, 8:38pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660 "2023-01-27T20:38:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [January 27, 2023, 8:38pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/1 "2023-01-27T20:38:33Z")

</div>

I have a “main” environment that has a lot of the packages I use. Whenever I want to try something out, I go to a new directory and I want to use those packages plus a couple of other packages.

- I don’t want to reinstall these main packages
- I don’t want to mutate-in-place the main environment with the new packages
- I want the project’s Project.toml and Manifest.toml to be complete, not relying on some external hidden state

Is it possible to get all three of these criteria? If not, how close can I get?

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [January 27, 2023, 8:54pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/2 "2023-01-27T20:54:17Z")

</div>

I tend to do a workflow pattern like this:

1. Activate default environment
2. Install packages I want available across all environments (for me, TerminalPager, IJulia, Revise, etc.)
3. Navigate to other project where I want to do things
4. Activate environment within the other project
5. Add packages you want for that specific project
6. Feel free to now use packages from the global separate environment and local project environment (any locally added packages are then written to the Project and Manifest tomls within that local environment)

I think that at least tackles your first two points although I am not sure about your third criterion.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [January 27, 2023, 8:57pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/3 "2023-01-27T20:57:46Z")

</div>

I do that for packages like Revise, where I don’t want them in the Project.toml at all. But here I’m talking about packages like CairoMakie which

- I want to use in many projects, and
- want it to be part of the Project.toml,
- but don’t want to wait for several minutes of installation.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [January 27, 2023, 8:59pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/4 "2023-01-27T20:59:16Z")

</div>

Like this:

> [@First Pluto notebook launches are slower on Julia 1.9 beta 3](https://discourse.julialang.org/t/first-pluto-notebook-launches-are-slower-on-julia-1-9-beta-3/93429/88):
>
> One workflow that might be nice interactively is something like ] activate --copy which creates a new environment that copies the current Project.toml and Manifest.toml over. That way you don’t have to pay a precompilation price when doing one-off things, but your state is saved if you want to return to it (even if your main environment changes).

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [January 27, 2023, 9:12pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/5 "2023-01-27T21:12:20Z")

</div>

I see. I often create another global environment called something like `pkg> activate @DATASCIENCE` (or something shorter) and then add packages (like CSV, Arrow, DataFrames, Makie, CairoMakie). Then, when I want to do quick analyses, I just drop into that environment. If I need something else specific, I deactivate that global environment and then activate the project environment, add the needed packages, use it, and then carry on my way. There should be a more elegant way of switching “main” environments, but this is the best workaround I have found.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [January 27, 2023, 11:59pm UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/6 "2023-01-27T23:59:20Z")

</div>

Check this attempt: [GitHub - feanor12/Draft.jl: A small package to automatically create temporary environments in offline mode.](https://github.com/feanor12/Draft.jl)

I think there are good ideas there.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 28, 2023, 7:05am UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/7 "2023-01-28T07:05:25Z")

</div>

The most straightforward solution is to copy the original project and manifest toml files into a new location and activate them there, but it would be nice if there was a shortcut for that. Then when adding new packages using the preserve-all flag to prohibit version changes.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [January 28, 2023, 8:14am UTC](https://discourse.julialang.org/t/workflow-for-forking-an-environment/93660/8 "2023-01-28T08:14:27Z")

</div>

This often triggers re/pre-compilation though because you’re using packages from different environments (which haven’t been resolved together)

Also, it breaks reproducibility for the same reason.
