# How do I stash the current Pkg environment for future use?

**URL:** <https://discourse.julialang.org/t/how-do-i-stash-the-current-pkg-environment-for-future-use/20908>\
**Category:** General Usage\
**Tags:** pkg\
**Created:** [February 17, 2019, 5:19pm UTC](https://discourse.julialang.org/t/how-do-i-stash-the-current-pkg-environment-for-future-use/20908 "2019-02-17T17:19:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [February 17, 2019, 5:19pm UTC](https://discourse.julialang.org/t/how-do-i-stash-the-current-pkg-environment-for-future-use/20908/1 "2019-02-17T17:19:03Z")

</div>

Assume I have a project using some packages which currently works, and I want to stash it away in case I need it again a year or so later. Is there an easy way to stash the current package environment, kind of like git stash?

I know I could manually construct a Project.toml and Manifest.toml with the current package versions, but I was hoping there was a way to automate this process.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [February 17, 2019, 6:10pm UTC](https://discourse.julialang.org/t/how-do-i-stash-the-current-pkg-environment-for-future-use/20908/2 "2019-02-17T18:10:59Z")

</div>

If you are running in the default Julia environment (that is, if you haven’t done `pkg> activate path/to/your/project`, then you already have a Manifest and Project file, and you can find them in `~/.julia/dev/environments/v1.1/` (or `/v1.0` if you’re using Julia 1.0).

If you want to preserve that global environment, I believe you can just copy those two files somewhere (preferrably somewhere under version control so you can track their changes in the future).

For example:

```bash
$ mkdir MyProject

$ cd myProject

# Copy the global environment into this project
$ cp ~/.julia/environments/v1.1/*.toml .

# Start Julia with this new environment
$ julia --project

# Make sure everything is working
(MyProject) pkg> test MyPackage

# Commit it
$ git init

$ git add Manifest.toml Project.toml

$ git commit -m "project works"
```

---

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [February 17, 2019, 8:43pm UTC](https://discourse.julialang.org/t/how-do-i-stash-the-current-pkg-environment-for-future-use/20908/3 "2019-02-17T20:43:34Z")

</div>

Nice. That works fine.

I do have a lot of packages installed though, most of which aren’t in use for this project. I should probably just get in the habit of giving each project its own environment.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [February 17, 2019, 9:06pm UTC](https://discourse.julialang.org/t/how-do-i-stash-the-current-pkg-environment-for-future-use/20908/4 "2019-02-17T21:06:59Z")

</div>

Yes, I’d definitely recommend creating a new environment for each project. I really like that workflow.

By the way, you can safely remove packages you don’t need from the MyProject environment (via `(MyProject) pkg> rm UselessPackage` ), and that will only update the MyProject project and manifest files, without affecting your global package environment. So it should be possible to slim down MyProject after the fact.
