# Using environments

**URL:** <https://discourse.julialang.org/t/using-environments/76982>\
**Category:** General Usage\
**Created:** [February 23, 2022, 4:49pm UTC](https://discourse.julialang.org/t/using-environments/76982 "2022-02-23T16:49:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Di11on](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/di11on/32/6352_2.png) [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Post date:** [February 23, 2022, 4:49pm UTC](https://discourse.julialang.org/t/using-environments/76982/1 "2022-02-23T16:49:02Z")

</div>

I’m trying to figure out how environments work in Julia. My understanding is that it creates a new empty package space where I can add different packages and work in isolation from other environments.

So I create my new environment and avtivate it and when I execute `Pkg.status()` I get an empty list, as I expect. However, when I execute `using somepackage` where somepackage is a package that needs adding but I haven’t added it yet, it works and I don’t get an error. somepackage exists in another environment, but I don’t want to use this - I want to dev somepackage to another folder somewhere in my new environment.

```julia
julia> using Pkg

julia> Pkg.status()
      Status `C:\Users\jodyd\.julia\environments\SpineOptDev\Project.toml` (empty project)

julia> using PyCall

julia> 

```

Can I do what I am trying to do?

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [February 23, 2022, 5:09pm UTC](https://discourse.julialang.org/t/using-environments/76982/2 "2022-02-23T17:09:13Z")

</div>

You probably have `PyCall` installed in your default environment (the one which is active when you don’t explicitly activate any other, and is named after the current julia version, i.e. something like `@vX.Y`)

This default environment is normally [stacked](https://docs.julialang.org/en/v1/manual/code-loading/#Environment-stacks) with the environment of the currently active project, so that any package missing from the currently active project can still be found in the default environment. Normally, you’d use this feature to put development tools (e.g. things like `Revise`, `Debugger` or `ProfileView`) in the default environment, so that you can use them when developing any project.

However, any package used in the code of you project should be explicitly `Pkg.add`ed as a dependency to it. And tools like `Pkg.test` should warn you if you forgot a dependency.

---

<div class="post-metadata">

**Author:** ![Di11on](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/di11on/32/6352_2.png) [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Post date:** [February 23, 2022, 5:22pm UTC](https://discourse.julialang.org/t/using-environments/76982/3 "2022-02-23T17:22:30Z")

</div>

Thanks for the reply.

What I am actually trying to do here is maintain two branches of a repository simultaneously - a master branch and development branch. In my default environment I have the master branch `dev`’d. My idea is to create a new environment and in that, dev a duplicate of the package but with a different branch checked out. Will this work? In my new project, if I simply `Pkg.dev(path\to\dev\repo)` will this do what I want?

Thanks!

---

<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:** [February 23, 2022, 5:31pm UTC](https://discourse.julialang.org/t/using-environments/76982/4 "2022-02-23T17:31:06Z")

</div>

I think you need two copies of the repo to do that. The `dev`’d branch will be that active on each copy.

(but note that you can switch between branches quite easily, and if you use `Revise`, when you switch branches, the current branch will be the one being tracked. So maybe you don’t really need two environments).
