# What does \`activate\` really do?

**URL:** <https://discourse.julialang.org/t/what-does-activate-really-do/32898>\
**Category:** General Usage\
**Created:** [January 2, 2020, 9:27pm UTC](https://discourse.julialang.org/t/what-does-activate-really-do/32898 "2020-01-02T21:27:20Z")\
**Posts on this page:** 3\
**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:** [January 2, 2020, 9:27pm UTC](https://discourse.julialang.org/t/what-does-activate-really-do/32898/1 "2020-01-02T21:27:20Z")

</div>

I don’t know why but I am having a terrible time understanding environments in Julia. I really want to understand what `activate` does and how one should use it. Here is just one of the things I am not wrapping my head around.

In my `v1.2` environment, I am able to `add` and `using` the `Bootstrap` package. That is,

```julia
julia> using Bootstrap
[Info: Precompiling Bootstrap [e28b5b4c-05e8-5b66-bc03-6f0c0a0a06e0]

julia>

```

If I exit and restart Julia, and switch my environment to a project I am working on (in `.julia/dev/`), it dosn’t compile.

```julia
(v1.2) pkg> activate thvaccine
Activating environment at `~/.julia/dev/thvaccine/Project.toml`

(thvaccine) pkg>

julia> using Bootstrap
[Info: Recompiling stale cache file /home/affans/.julia/compiled/v1.2/Bootstrap/0NS1M.ji for Bootstrap [e28b5b4c-05e8-5b66-bc03-6f0c0a0a06e0]
ERROR: LoadError: UndefVarError: levels not defined
Stacktrace:
 [1] include at ./boot.jl:328 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1094
 [3] include(::Module, ::String) at ./Base.jl:31
 [4] top-level scope at none:2
 [5] eval at ./boot.jl:330 [inlined]
 [6] eval(::Expr) at ./client.jl:432
 [7] top-level scope at ./none:3
in expression starting at /home/affans/.julia/packages/StatsModels/9cHwk/src/StatsModels.jl:7
ERROR: LoadError: Failed to precompile StatsModels [3eaba693-59b7-5ba5-a881-562e759f1c8d] to /home/affans/.julia/compiled/v1.2/StatsModels/4MFnV.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1253
 [3] _require(::Base.PkgId) at ./loading.jl:1013
 [4] require(::Base.PkgId) at ./loading.jl:911
 [5] require(::Module, ::Symbol) at ./loading.jl:906
 [6] include at ./boot.jl:328 [inlined]
 [7] include_relative(::Module, ::String) at ./loading.jl:1094
 [8] include(::Module, ::String) at ./Base.jl:31
 [9] top-level scope at none:2
 [10] eval at ./boot.jl:330 [inlined]
 [11] eval(::Expr) at ./client.jl:432
 [12] top-level scope at ./none:3
in expression starting at /home/affans/.julia/packages/Bootstrap/QldPq/src/Bootstrap.jl:13
ERROR: Failed to precompile Bootstrap [e28b5b4c-05e8-5b66-bc03-6f0c0a0a06e0] to /home/affans/.julia/compiled/v1.2/Bootstrap/0NS1M.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1253
 [3] _require(::Base.PkgId) at ./loading.jl:1013
 [4] require(::Base.PkgId) at ./loading.jl:911
 [5] require(::Module, ::Symbol) at ./loading.jl:906

```

I am assuming this has something to do with my `Project.toml` files, and something with the wrong versions of `StatsModel`. My project dosn’t really depend on `Bootstrap` so I don’t want to add it to the project’s `Project.toml` file. I do want the package installed in my global environment for data analysis. I do want to be able to say `using Bootstrap` even when I am in my project’s environment. As far as I remember, `using` should pull the package from my `v1.2` environment.

Is there a summary/blog post of how environments/`activate` really work?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [January 2, 2020, 10:21pm UTC](https://discourse.julialang.org/t/what-does-activate-really-do/32898/2 "2020-01-02T22:21:47Z")

</div>

My attempt at a summary is [here](https://lhendricks.org/julia_notes.pdf). Hope it is useful.

---

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [January 2, 2020, 10:32pm UTC](https://discourse.julialang.org/t/what-does-activate-really-do/32898/3 "2020-01-02T22:32:36Z")

</div>

The _excellent_ [Pkg presentation](https://www.youtube.com/watch?v=q-LV4zoxc-E) from ~~this~~ last year Juliacon may be helpful. There is a [Pkg manual chapter](https://docs.julialang.org/en/v1/stdlib/Pkg/) and the [Pkg documentation](https://julialang.github.io/Pkg.jl/v1/getting-started/). It’s nice (but I find it quite difficult because there is so much (high/low level) material - I must read it again…😉 )

`activate` switched/created a new environment (defined by two files, ~/.julia/dev/thvaccine/Project.toml and …Manifest.toml). In the `(thvaccine) pkg>` prompt you may check what is in this environment with `status`. With `instantiate` you ensure that everything needed has been downloaded and installed. Did you `(thvaccine) pkg> add StatsModel` here?

I’m not sure about your Bootstrap error. In principle it is perfectly fine that this package will be taken from the default, i.e. v1.2, environment. `> LOAD_PATH` displays the paths.

Maybe the problem goes away after you have `instantiate`d the thvaccine environment?
