# Replace (as opposed to add to) the default environment

**URL:** https://discourse.julialang.org/t/replace-as-opposed-to-add-to-the-default-environment/21175
**Category:** General Usage
**Tags:** pkg
**Created:** [February 25, 2019, 3:04pm UTC](https://discourse.julialang.org/t/replace-as-opposed-to-add-to-the-default-environment/21175 "2019-02-25T15:04:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![krcools](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krcools/32/10212_2.png) [@krcools](https://discourse.julialang.org/u/krcools)
#### Post date: [February 25, 2019, 3:04pm UTC](https://discourse.julialang.org/t/replace-as-opposed-to-add-to-the-default-environment/21175/1 "2019-02-25T15:04:04Z")

</div>

One of the reasons to introduce Pkg3 and the code loading rules was to make projects more reproducible.

This is why the following behaviour surprised me: when I switch to a new environment (`] activate myenv`), it is added to the environment stack (which now looks like `[myenv, v1.0, stdlib]`). This makes it difficult to make sure that I am not relying on packages that are part of the default environment, but not `myenv` and thus that submitting the manifest for `myenv` provides a full working environment to the end user.

Is there a way to replace the default environment instead of adding to the env-stack?

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [February 25, 2019, 3:13pm UTC](https://discourse.julialang.org/t/replace-as-opposed-to-add-to-the-default-environment/21175/2 "2019-02-25T15:13:44Z")

</div>

> [@krcools](#):
>
> Is there a way to replace the default environment instead of adding to the env-stack?

You can change your `LOAD_PATH` to be `["@", "@stdlib"]` instead of the default `["@", "v#.#", "@stdlib"]`. This can be accomplished by doing

```sh
export JULIA_LOAD_PATH="@:@stdlib"

```

in one of your shell startup scripts. Note, however, that having `v1.0` in the environment stack only allows you to load packages in there from `Main` (so from the REPL or standalone scripts) and package code that doesn’t have any project file. From within code that does have a project file, you can only load dependencies that are explicitly declared in the project file’s `[deps]` section.

---

<div class="post-metadata">

### Author: ![krcools](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krcools/32/10212_2.png) [@krcools](https://discourse.julialang.org/u/krcools)
#### Post date: [February 25, 2019, 3:32pm UTC](https://discourse.julialang.org/t/replace-as-opposed-to-add-to-the-default-environment/21175/3 "2019-02-25T15:32:01Z")

</div>

Thank you.

> [@StefanKarpinski](#):
>
> Note, however, that having `v1.0` in the environment stack only allows you to load packages in there from `Main` (so from the REPL or standalone scripts) and package code that doesn’t have any project file. From within code that does have a project file, you can only load dependencies that are explicitly declared in the project file’s `[deps]` section.

Yes, I am aware. I encountered this in trying to package a script (not a package). It worries me slightly though that this relies on the end-user to take action to set up the environment. Can I edit LOAD\_PATH in the preamble to my script? I guess it should not matter as the packages installed on their machine are shadowed by my provided manifest…

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [February 25, 2019, 3:38pm UTC](https://discourse.julialang.org/t/replace-as-opposed-to-add-to-the-default-environment/21175/4 "2019-02-25T15:38:50Z")

</div>

> [@krcools](#):
>
> Can I edit LOAD\_PATH in the preamble to my script?

Yes, just modify `LOAD_PATH` before loading packages.

Having a standard mechanism for providing scripts to users and running them with the right environment setup is a good thing that we’ll want to figure out a standard way to do in the future. I can imagine something like Julia scripts in the `bin` directory of a package being run from the package’s environment.
