# 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:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [March 22, 2019, 7:59am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/1 "2019-03-22T07:59:25Z")

</div>

When using julia on my enviroment /home/johnsmith/julia

If I want to start a new project say ProjectA, I would create the directory

```julia
/home/johnsmith/julia/project/projectA

```

then active it using the command

```julia
julia>]
(v1.0) pkg> activate /home/johnsmith/julia/project/projectA

```

Now after I finished with projectA for the time being, and want to get back to normal, the following command does not work

```julia
(v1.0) pkg> deactivate /home/johnsmith/julia/project/projectA

```

So how do I get back to the state I was in before I activate projectA?

---

<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:** [March 22, 2019, 8:01am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/2 "2019-03-22T08:01:34Z")

</div>

> [@StevenSiew](#):
>
> So how do I get back to the state I was in before I activate projectA?

Just use `activate` with no argument

```julia-auto
pkg> activate

```

> [@StevenSiew](#):
>
> the following command does not work

What made you think there was a `deactivate` command?

---

<div class="post-metadata">

**Author:** ![maxmouchet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxmouchet/32/7834_2.png) [@maxmouchet](https://discourse.julialang.org/u/maxmouchet)\
**Post date:** [March 22, 2019, 9:01am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/3 "2019-03-22T09:01:43Z")

</div>

For what it’s worth, there is an `activate` and a `deactivate` command in Conda/Python.  
I find it better from a discoverability point of view, as most commands tends to have an opposite one (`apt install/remove`, `Pkg.add/Pkg.rm`, …).

---

<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:** [March 22, 2019, 9:13am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/4 "2019-03-22T09:13:30Z")

</div>

Think of `activate` in Julia as `cd` in the terminal. Just like `cd` takes you back to your home directory, `activate` takes you to your home project.

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [March 22, 2019, 9:07pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/5 "2019-03-22T21:07:13Z")

</div>

Would it not be better if julia has a deactivate command which does not take any argument or ignores any arguments and all it does is an alias for activate with no arguments?

This would make it simple for learners to grasp the concept.

If you go through the documentation of Julia in the eyes of a newbie, see if you can figure out that the command activate with no argument is the same as deactivate.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 23, 2019, 2:35pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/6 "2019-03-23T14:35:50Z")

</div>

> [@StevenSiew](#):
>
> If you go through the documentation of Julia in the eyes of a newbie, see if you can figure out that the command activate with no argument is the same as deactivate.

If you think the documentation is can be improved, please open an issue or (ideally) make a PR. It is undeed true that the documentation does not give an example for `pkg> activate` without arguments, so that could be remedied. Somewhat related:

> <https://github.com/JuliaLang/Pkg.jl/issues/746>
>
> @mschauer commented on \[Sat Sep 15 2018\](https://github.com/JuliaLang/julia/issu…es/29199)
> 
> I wanted to give feedback on some hidden assumptions and things unclear to me which might help in writing the docs.
> 
> \* Does \`activate\` "do" something or does it only change a status? Does this status only affect \`LOAD\_PATH\` and \`Pkg\`?
> \* Does \`activate\` have any permanent or global effects, or only affect the current Julia process. 
> \* Activate's docstring mentions a \`home project environment\` but that is not in the glossary. There is also a circularity here I do not understand: Quoting "If no argument is given to activate, activate the home project, which is the one specified by either --project command line when starting julia, or JULIA\_PROJECT environment variable." What if no project-command is given and no JULIA\_PROJECT is defined which is the standard? Similar issue with "The depot path is controlled by the Julia DEPOT\_PATH global variable which is populated at startup based on the value of the JULIA\_DEPOT\_PATH environment variable" This seems to have a default \`~/.julia\`?
> \* " The active environment is the environment that is
> modified by executing package commands." Confusing, does not apply to \`generate\` for example.
> \* The apparent difference between \`current\` and \`active\` project is too subtile, a warning should be added.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [October 3, 2019, 4:27pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/7 "2019-10-03T16:27:07Z")

</div>

I came across this because I reached for “deactivate” before trying “activate” without any arguments.

Seems like having “deactivate” be an alias for this would make things easier on the user. And as we have discussed before, the pkg command line is intended to be more intuitive/do-what-I-mean, yes?

Is there a reason to not have “deactivate”?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 3, 2019, 5:07pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/8 "2019-10-03T17:07:15Z")

</div>

> [@Tamas\_Papp](#):
>
> the documentation does not give an example for `pkg> activate` without arguments, so that could be remedied.

I don’t know how the status was when this was written but now

```julia
help?> Pkg.activate
  Pkg.activate([s::String]; shared::Bool=false)

...

  If no argument is given to activate, then activate the home project. The home project is specified by either the --project command line option to the julia executable, or the
  JULIA_PROJECT environment variable.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  Pkg.activate()
  Pkg.activate("local/path")
  Pkg.activate("MyDependency")

```

```julia
(v1.3) pkg> ?activate
  activate
  activate [--shared] path

  Activate the environment at the given path, or the home project environment if no path is specified. 
...
```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 3, 2019, 5:48pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/9 "2019-10-03T17:48:41Z")

</div>

I think this was about the docs, not the docstrings, but even there I am mistaken, since this has been part of Pkg since

[https://github.com/JuliaLang/Pkg.jl/pull/1023](https://github.com/JuliaLang/Pkg.jl/pull/1023)

---

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [February 28, 2020, 8:45am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/10 "2020-02-28T08:45:47Z")

</div>

I think it should be added in the document. Most users check the document for new command. It takes me some time to get the answer here rather than the document.

[https://docs.julialang.org/en/v1/stdlib/Pkg/index.html](https://docs.julialang.org/en/v1/stdlib/Pkg/index.html)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 28, 2020, 8:50am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/11 "2020-02-28T08:50:52Z")

</div>

The docstrings are included in the documentation, too:

[https://julialang.github.io/Pkg.jl/dev/api/#Pkg.activate](https://julialang.github.io/Pkg.jl/dev/api/#Pkg.activate)

---

<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:** [February 28, 2020, 9:42am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/12 "2020-02-28T09:42:59Z")

</div>

While true I think our documentation is still not as good as it could be. I think the relevant sentence

> If no argument is given to `activate` , then activate the home project. The home project is specified by either the `--project` command line option to the julia executable, or the `JULIA_PROJECT` environment variable.

could be confusing for a beginner. What if I neither started Julia with `--project` nor set the `JULIA_PROJECT` environment variable and do `] activate`? It’s not clear from the docstring what will happen in this case.

Also, note the use of the term “home project”. I reckon the difference between “home project” and “default project” (v1.x) is subtle to a beginner who, again, likely hasn’t specified a “home project”. In this context, let me also mention that the “default project” (v1.x) - which by default is equal to the “home project” - is special in the sense that it is (by another default) also the “global project”. A fact which is also not as clear from the documentation as it could be (you have to read about the `LOAD_PATH` to understand this, an advanced concept in my opinion).

As has been discussed on Slack at some point (@davidanthoff) I personally think that the “default project” shouldn’t be equal to the “global environment” (the one which automatically is in the `LOAD_PATH`) to begin with. I’d like extra syntax like `] add --global MyPackage` for adding a package to a separate global environment. This way, confusions like [this one, which came up just yesterday,](https://discourse.julialang.org/t/ann-mybinder-org-support-for-julia-1-x-and-project-toml/22522/28) could be easily avoided.

In any case, I think that the Pkg documentation in its entirety explains almost all features/mechanisms, but individual sections can be pretty confusing without reading the rest of the docs. I think we can do better and I hope to find the time to make a few PRs soon.

---

<div class="post-metadata">

**Author:** ![Karajan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karajan/32/8545_2.png) [@Karajan](https://discourse.julialang.org/u/Karajan)\
**Post date:** [February 28, 2020, 10:07am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/13 "2020-02-28T10:07:03Z")

</div>

Just to make you point: half of what you just said was news to me. There is a “home project” that is different from the “default project”?!

---

<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:** [February 28, 2020, 10:11am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/14 "2020-02-28T10:11:35Z")

</div>

The “home project” is what you specify through `--project` or `JULIA_PROJECT`. By default, that is if you havent specified either, “home project” === “default project” (v1.x).

See what happens on `] activate` after

- starting julia with `julia` and `] activate .`
- starting julia with `julia --project=.`

The first one will bring you back to the home (=== default) project, v1.x. The second will bring you back to the home project == local project (you’re already there so nothing will happen).

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 28, 2020, 11:23am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/15 "2020-02-28T11:23:19Z")

</div>

> [@carstenbauer](#):
>
> I think we can do better and I hope to find the time to make a few PRs soon.

That would be great. I think this is not only a question of documenting these concepts well, but also providing examples of how people typically use them in their workflow. The workflow section

[https://docs.julialang.org/en/v1/manual/workflow-tips/](https://docs.julialang.org/en/v1/manual/workflow-tips/)

could also benefit from a `Pkg`-centric rewrite.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [August 17, 2020, 5:38pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/16 "2020-08-17T17:38:54Z")

</div>

I encountered an issue where this doesn’t work as expected.

At least in the VSCode REPL, it will default to the package directory. But `]activate` alone does not cause it to drop back to the main Julia environment `@1.5`. Instead it stays on the package directory.

What is the command to load the global default environment if you’re “stuck” in the local project?

In my case, I want to load a temporary package like BenchmarkTools without worrying about it going into my Project.toml.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 17, 2020, 5:55pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/17 "2020-08-17T17:55:12Z")

</div>

> [@BioTurboNick](#):
>
> At least in the VSCode REPL, it will default to the package directory. But `]activate` alone does not cause it to drop back to the main Julia environment `@1.5` . Instead it stays on the package directory.
> 
> What is the command to load the global default environment if you’re “stuck” in the local project?

```julia
activate --shared v1.5

```

However, I think @StefanKarpinski had plans on changing this so that `activate` always brings you back to the v1.x environment.

---

<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:** [August 17, 2020, 8:31pm UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/18 "2020-08-17T20:31:51Z")

</div>

There’s a PR: [https://github.com/JuliaLang/Pkg.jl/pull/1891](https://github.com/JuliaLang/Pkg.jl/pull/1891). I plan on finishing it up for 1.6, just need to fix the tests that the API change broke and merge it. If anyone wants to help, they’re welcome to fix the tests 😁

---

<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, 8:42am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/19 "2021-05-07T08:42:52Z")

</div>

After reading this thread and the [docs](https://pkgdocs.julialang.org/dev/api/#Pkg.activate), I do have a question, which I hope I will be forgiven for asking here: Does starting up Julia necessarily activate a default environment?

And if that’s the case, then to “deactivate” it, I can just activate some/any other environment? I’m not trying to be pedantic about the wording, it’s just that I want to make sure that `Pkg.activate(; temp=true)` will safely take me out of the previous environment once and for all. Thanks.

---

<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, 9:24am UTC](https://discourse.julialang.org/t/julia-is-missing-the-deactivate-command/22185/20 "2021-05-07T09:24:03Z")

</div>

> [@ptoche](#):
>
> Does starting up Julia necessarily activate a default environment?

No, by default you have no active environment (in the sense of `Pkg.activate`). Perhaps [what is `@.` in Julia `--project` command line option? - Stack Overflow](https://stackoverflow.com/a/53624158) clarifies things a bit.

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