# Julia is missing the deactivate command

**URL:** <https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185>\
**Category:** New to Julia\
**Created:** [March 22, 2019, 7:59am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185 "2019-03-22T07:59:25Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 7, 2021, 12:11pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/21 "2021-05-07T12:11:28Z")

</div>

Thanks for the link. 👍 I’ll have to read that a few times.

`Base.active_project()` returns the path to a `Project.toml` even at startup, but that’s not quite the same as activating project… subtle.

Instead of trying to guess where `Pkg.activate()` will take me, I think I’d rather be explicit with something like:

```
cd("path/to/toml")
import Pkg
Pkg.activate(".")
Base.active_project() # check you're where you think you are

```

Thanks again Fredrik

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [May 7, 2021, 12:22pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/22 "2021-05-07T12:22:20Z")

</div>

I think you’re looking for what was written [here](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/2), you just need to type  
`activate`  
(with no argument) in package mode.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 7, 2021, 12:34pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/23 "2021-05-07T12:34:18Z")

</div>

By default the load path is

```julia
julia> Base.LOAD_PATH
3-element Vector{String}:
 "@"
 "@v#.#"
 "@stdlib"

```

where `@` is essentially a “pointer” to an active project. By default it doesn’t point to anything, it exands to nothing

```julia
julia> Base.load_path()
2-element Vector{String}:
 "/home/fredrik/.julia/environments/v1.6/Project.toml" # expansion of @v#.# in LOAD_PATH
 "/opt/julia/julia-1.6.1/share/julia/stdlib/v1.6" # expansion of @stdlib in LOAD_PATH

```

If you `Pkg.activate` something you set the pointer to the thing you activated

```julia
julia> using Pkg; Pkg.activate("/tmp")

julia> Base.load_path()
3-element Vector{String}:
 "/tmp/Project.toml"
 "/home/fredrik/.julia/environments/v1.6/Project.toml"
 "/opt/julia/julia-1.6.1/share/julia/stdlib/v1.6"

```

and then `Pkg.activate()` (no argument) sets the pointer to “null” again:

```julia
julia> Pkg.activate()

julia> Base.load_path()
2-element Vector{String}:
 "/home/fredrik/.julia/environments/v1.6/Project.toml"
 "/opt/julia/julia-1.6.1/share/julia/stdlib/v1.6"

```

The `--project` command line flag, and the `JULIA_PROJECT` environment variable are other ways to set the pointer, similar to `Pkg.activate`.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 7, 2021, 12:40pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/24 "2021-05-07T12:40:00Z")

</div>

Thanks magister-ludi. Well I’m not so clear about the analogy with `cd`. It sounds as if once a project has been activated, the only way to deactivate it is to activate another project. I’m not sure I understand [it](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/2).

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 7, 2021, 12:43pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/25 "2021-05-07T12:43:14Z")

</div>

> [@fredrikekre](#):
>
> `Pkg.activate()` (no argument) sets the pointer to “null” again:

Thanks Fredrik, it’s much clearer now. I was confused when `Base.active_project()` was not returning a null pointer, but if you say it’s null I’ll take your word for it. 👍

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [May 7, 2021, 12:44pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/26 "2021-05-07T12:44:20Z")

</div>

I think the analogy is that in UNIX-like systems, `cd` without an argument takes you back to a a kind of ‘base state’, which is the home directory. So `activate` without an argument takes you back to the ‘no specific package loaded’ state.

Edit: I mean no specific package **activated**.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 7, 2021, 12:50pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/27 "2021-05-07T12:50:19Z")

</div>

> [@magister-ludi](#):
>
> takes you back to a a kind of ‘base state’,

yes, thanks. I was just not sure if that ‘base state’ was considered active or not. 😅

---

<div class="post-metadata">

**Author:** ![aiqc](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@aiqc](https://discourse.julialang.org/u/aiqc)\
**Post date:** [October 7, 2021, 7:49pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/28 "2021-10-07T19:49:14Z")

</div>

I came here looking for `deactivate()`

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [December 3, 2021, 1:03pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/29 "2021-12-03T13:03:44Z")

</div>

**status remark for v1.7.0:**  
I found confusing information regarding the environment variable “JULIA\_LOAD\_PATH”.  
On the [page about environment variables](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_LOAD_PATH) it is stated:

> Unlike the shell `PATH` variable, empty entries in `JULIA_LOAD_PATH` are expanded to the default value of `LOAD_PATH` , `["@", "@v#.#", "@stdlib"]` when populating `LOAD_PATH` . This allows easy appending, prepending, etc. of the load path value in shell scripts regardless of whether `JULIA_LOAD_PATH` is already set or not. For example, to prepend the directory `/foo/bar` to `LOAD_PATH` just do.

But under windows I have the impression that this is not true. Here is what I have added in my `startup.jl`:

```julia
s_modul_path = raw"C:\data\julia\MyLib"
ENV["JULIA_LOAD_PATH"] = s_modul_path

```

The startup file is executed at start up, I can see the welcome massage that is included.  
My expectation was, that modules that are located in this folder will be found,  
unfortunately this is not the case.

---

<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:** [December 3, 2021, 1:07pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/30 "2021-12-03T13:07:05Z")

</div>

- `JULIA_LOAD_PATH` != `JULIA_DEPOT_PATH`
- Once Julia is started, both environment variables have been processed and changing them won’t have any effect.
- To modifiy the load or depot path (stack) you need to modify the `LOAD_PATH` or `DEPOT_PATH` variables, respectively.

So I’d try something like `push!(LOAD_PATH, s_modul_path)`.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [December 3, 2021, 1:43pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/31 "2021-12-03T13:43:12Z")

</div>

> [@carstenbauer](#):
>
> push!(LOAD\_PATH, s\_modul\_path)

Yes, this works fine. In fact this is the method I use. 🙂  
But I wonder, if the information about `JULIA_LOAD_PATH` is correct.  
The following does not work:

```julia
ENV["JULIA_LOAD_PATH"] = string("C:\\data\\julia\\MyLib", ";", ENV["JULIA_LOAD_PATH"])

```

I hope this is the correct translation of the unix example:

```julia
export JULIA_LOAD_PATH="/foo/bar:$JULIA_LOAD_PATH"

```

The error message is:

```julia
LoadError: KeyError: key "JULIA_LOAD_PATH" not found

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [December 3, 2021, 2:00pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/32 "2021-12-03T14:00:16Z")

</div>

It is not set by default, so you need something like

```julia
ENV["JULIA_LOAD_PATH"] = string("C:\\data\\julia\\MyLib", ";", get(ENV, "JULIA_LOAD_PATH", ""))

```

to mimic the shell behavior of just inserting an empty string for missing variables. (However, as noted above it is too late to change this once already in Julia.)

---

<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:** [December 3, 2021, 7:50pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/33 "2021-12-03T19:50:09Z")

</div>

You need to set the environment variable before starting Julia. Once you’re in Julia you can just manipulate the contents of `LOAD_PATH` directly.

[Previous page](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185.md?page=1)
