VSCode environments getting mixed up


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?

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.

See:

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

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.

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).

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:

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:

> 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:

> 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
[...]

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

not the one shown in the Julia env line:
image

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?

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