VS Code's built-in REPL does not seem to work with new contextual module repl under Julia 1.9

VS Code’s built-in REPL, launched by alt-J alt-O, allows to execute code blocks from editor with shortcuts, thus quite useful in code development. Recent Julia 1.9 includes the very welcoming new feature of switching to a module environment, referred to as contextual module REPL in the following page.

However, in VS code’s built-in REPL mentioned above, I can activate an imported module, but can’t seem to actually enter the environment:

(julia) pkg> 

julia> import Plots

julia> plot
ERROR: UndefVarError: `plot` not defined

(Plots) julia> plot
ERROR: UndefVarError: `plot` not defined

julia> using Plots

julia> plot
plot (generic function with 4 methods)

(Plots) julia> plot
plot (generic function with 4 methods)

(Plots) julia> a=rand()
0.07311357566664356

julia> a
0.07311357566664356

Here by entering the Plots.jl module environment, I can’t seem to access its members. I created the variable a and returned to the Main module, I still had access to that variable.

If I open a REPL from (integrated) bash, things seem to work correctly:

(@v1.9) pkg> activate .
  Activating project at `~/julia`

julia> import Plots

julia> plot
ERROR: UndefVarError: `plot` not defined

(Plots) julia> plot
plot (generic function with 4 methods)

(Plots) julia> a=rand()
0.33426183870409865

julia> 

julia> a
ERROR: UndefVarError: `a` not defined

julia> a=rand()
0.9991814038049677

(Plots) julia> a
0.33426183870409865

(Plots) julia> 

I would like to use the built-in REPL for its integration with the editor, but would like to be able to activate a module environment temporarily. What settings do I need to change in VS code to make this happen? Thanks a lot. I’m using VS code 1.80 under WSL ubuntu 20, with Julia extension 1.47.2.

1 Like

Will be fixed with feat: support for REPL module switching by pfitzseb · Pull Request #3367 · julia-vscode/julia-vscode · GitHub.

2 Likes