# VSCode environments getting mixed up

**URL:** <https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889>\
**Category:** General Usage\
**Created:** [May 11, 2022, 2:15pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889 "2022-05-11T14:15:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 11, 2022, 2:15pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/1 "2022-05-11T14:15:46Z")

</div>

![InkedScreenHunter 418_LI](https://global.discourse-cdn.com/julialang/original/3X/7/7/77caa1b0e47d5a3e72e0c2a01baaa320e99a1420.jpeg)  
I have chosen an environment, as shown by the downward arrow.  
However, when I execute the file, it gets executed in the wrong environment: it is the environment  
I got by “open folder”.

Is this a bug, or am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 11, 2022, 3:00pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/2 "2022-05-11T15:00:52Z")

</div>

The environment in which the integrated REPL starts coincides with the environment chosen in the VS Code extension (the one indicated in the bottom bar) _at that moment_. After that, changing the environment in the extension does not affect the current environment of the REPL (you have to do it manually with `]activate xxx`, or either stop and restart the REPL session).

It looks as if you started the REPL when the environment set in the extension was the root folder, and changed it to `examples` afterwards.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 11, 2022, 3:03pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/3 "2022-05-11T15:03:33Z")

</div>

See:

> <https://github.com/julia-vscode/julia-vscode/issues/1226>
>
> Changing the environment via the Command Palette does not affect the environment… in the integrated REPL, and vice versa. What is the relationship between these two environments? Should they be the same?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 11, 2022, 3:22pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/4 "2022-05-11T15:22:27Z")

</div>

I am a bit lost. What is the point of changing the env? (The downward arrow.) How does one use it?

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 11, 2022, 3:59pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/5 "2022-05-11T15:59:19Z")

</div>

I know two utilities:

1. It’s the environment that is used when you start a Julia process, so that you don’t have to set/change it manually. That’s useful if, e.g. you want to run a script with the “play button”.
2. If you have the setting `julia.useCustomSysimage` set and there is a sysimage in the folder of that environment, it is automatically used when you start the integrated REPL.

Perhaps there are more features associted to it that I don’t know.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 11, 2022, 5:27pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/6 "2022-05-11T17:27:16Z")

</div>

My question was about “change env”. Is this useful in any way?  
I can’t get anything to run in the env once I change to it. Everything always  
runs in the original env to which I opened a folder (vscode command: open folder).

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 11, 2022, 8:00pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/7 "2022-05-11T20:00:17Z")

</div>

Not exactly: processes that are already started (e.g. integrated REPL) do not change their active environment if you change it through the VS Code command. But it does affect to new processes.

An example: I have an environment whose `Project.toml` has CSV in `[deps]`, and this file:

```julia
using CSV
println("done!")

```

By default the env marked in he VS Code bottom bar is my “root folder” `example_env`; so I choose `Julia: Run File in New Process` and get this in the terminal:

```julia
> Executing task: julia --color=yes --project=/home/meliana/julia_sandbox/example_env /home/meliana/julia_sandbox/example_env/test.jl <

done!

```

Now I change the environment to “v1.7” (where I don’t have CSV) and when I try `Julia: Run File in New Process` again:

```julia
> Executing task: julia --color=yes --project=/home/meliana/.julia/environments/v1.7 /home/meliana/julia_sandbox/example_env/test.jl <

ERROR: LoadError: ArgumentError: Package CSV not found in current path:
- Run `import Pkg; Pkg.add("CSV")` to install the CSV package.

Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:967
[...]

```

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 11, 2022, 9:21pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/8 "2022-05-11T21:21:26Z")

</div>

I change the env, then stop the repl, then start a repl. This new repl starts in the old env,

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/c/fc61621ee863487c351f1b2717383d937117455d.png)

not the one shown in the Julia env line:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/f/4fb0a66e20cd9683601752c94b7467c3118712d1.png)

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 12, 2022, 7:51am UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/9 "2022-05-12T07:51:33Z")

</div>

Strange. I do exactly the same and in my case the new repl does start in the environment shown in the Julia “env” line (as shown in the prompt after typing `]`).

Maybe something in the setting `julia.environmentPath`?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 12, 2022, 2:23pm UTC](https://discourse.julialang.org/t/vscode-environments-getting-mixed-up/80889/10 "2022-05-12T14:23:28Z")

</div>

This particular setting (`julia.environmentPath`) is an empty string. Not sure what it should be.
