# Pkg environment is sticky (Julia v0.7-beta)

**URL:** <https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925>\
**Category:** Internals & Design\
**Created:** [June 25, 2018, 9:51am UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925 "2018-06-25T09:51:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iagoba\_Apellaniz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iagoba_apellaniz/32/34406_2.png) [@Iagoba\_Apellaniz](https://discourse.julialang.org/u/Iagoba_Apellaniz)\
**Post date:** [June 25, 2018, 9:51am UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/1 "2018-06-25T09:51:39Z")

</div>

I find this a bit annoying

```julia
shell> mkdir Test & cd Test

(v0.7) pkg> init # or generate
Initialized project at /home/.../Test/Project.toml

(Test) pkg>

```

Now if I move on the directory tree, the environment for Pkg is still `Test`

```julia
julia> cd()

(Test) pkg>

```

Is this intended or is it a bug?

Version info:

```julia
Julia Version 0.7.0-beta.7
Commit 0978251 (2018-06-25 01:11 UTC)
Platform Info:
  OS: Linux (x86_64-redhat-linux)
  CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

```

In case it is a bug, I’ll just copy paste this into GitHub. Thanks

---

<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:** [June 25, 2018, 11:13am UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/2 "2018-06-25T11:13:39Z")

</div>

On newest master `init` will activate the new environment but `cd` ing into a new environment will not activate it. It requires an explicit `pkg> activate` command. The reason for this is that it was deemed dangerous to change what code was being loaded based on the mere existence of a file.

It will be possbile to opt into the old `cd` → `activate` behavior.

---

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [June 25, 2018, 11:57am UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/3 "2018-06-25T11:57:00Z")

</div>

May I ask, why it is dangerous? Was the file meant `Project.toml`? Is it similar to the Python case of ` __init__.py`?

---

<div class="post-metadata">

**Author:** ![Iagoba\_Apellaniz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iagoba_apellaniz/32/34406_2.png) [@Iagoba\_Apellaniz](https://discourse.julialang.org/u/Iagoba_Apellaniz)\
**Post date:** [June 25, 2018, 12:23pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/4 "2018-06-25T12:23:01Z")

</div>

How could I `activate` the `v0.7` “global” environment without going exactly to where `v0.7` project file is?

Thanks

---

<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:** [June 25, 2018, 12:44pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/5 "2018-06-25T12:44:09Z")

</div>

That one is active by default. If you `pkg> activate` you can `pkg> deactivate` to go back to the 0.7 one.

> [@innerlee](#):
>
> May I ask, why it is dangerous? Was the file meant `Project.toml` ? Is it similar to the Python case of ` __init__.py` ?

See discussion in e.g. [https://github.com/JuliaLang/julia/pull/27633](https://github.com/JuliaLang/julia/pull/27633)

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [July 9, 2018, 1:20pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/6 "2018-07-09T13:20:03Z")

</div>

Not sure if this is 100% relevant to the discussion – I was about to post a new topic, but was directed here. I’m probably just confused, but when I start `Pkg` interactively (having deleted `~/.julia`), I get, say, `(foo) pkg>` if I have `.` in my load path (I’ve seen some discussion about that), but if I don’t, I seem to just get `pkg>` – I don’t see `(v0.7) pkg>`. And `activate` doesn’t seem to change anything. (And `deactivate` doesn’t see to exist…?)

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [July 9, 2018, 1:41pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/7 "2018-07-09T13:41:32Z")

</div>

See also [Is there a replacement for ‘deactivate’? · Issue #464 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/issues/464)

I wonder if it would be useful to have the stdlibs added as topics under development on discourse.

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [July 9, 2018, 2:18pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/8 "2018-07-09T14:18:10Z")

</div>

Thanks. Doesn’t seem to solve my issue, though.

---

<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:** [July 9, 2018, 4:17pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/9 "2018-07-09T16:17:32Z")

</div>

What I’d your `LOAD_PATH` and what does `Base. active_project()` say?

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [July 9, 2018, 5:19pm UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/10 "2018-07-09T17:19:36Z")

</div>

Aah, that’s the issue. The `LOAD_PATH` contains some directories I added myself (by setting `JULIA_LOAD_PATH`), and `Base.active_project()` was empty. If I don’t set `JULIA_LOAD_PATH` in my shell, all is well, it seems, with `LOAD_PATH` containing `@`, `@v#.#` and `@stdlib`.

I guess there’s some magic here I haven’t picked up yet. [The docs](https://docs.julialang.org/en/latest/manual/modules/) still say that `LOAD_PATH` can be “extended” by defining `JULIA_LOAD_PATH`, but it seems it’s simply overwritten. I guess this is part of the [simplification](https://github.com/JuliaLang/julia/pull/27633).

Now, I had no idea that such things as described there were possible (i.e., inserting `$JULIA_LOAD_PATH` in the shell actually inserting it in Julia, even if `$JULIA_LOAD_PATH` is empty), so I hadn’t bothered including it. Adding it fixed everything – I should have read [#27633](https://github.com/JuliaLang/julia/pull/27633) more carefully! (Or … is it just that the path ends with `:`? That seems to work, too, and is less of a magical explanation.)

Anyway, thanks! 😃

---

<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:** [July 10, 2018, 2:05am UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/11 "2018-07-10T02:05:27Z")

</div>

Sorry, I need to write docs. This design was finalized and implemented last week and I haven’t gotten a chance to document it yet.

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [July 10, 2018, 8:00am UTC](https://discourse.julialang.org/t/pkg-environment-is-sticky-julia-v0-7-beta/11925/12 "2018-07-10T08:00:19Z")

</div>

Fully understandable!
