VSCode REPL Namespaces/Modules

How is this still happening? How are you living with this? I expected the REPL module switching released with Julia 1.9 to fix this issue.

(DataFrames) julia> x = 3 # Ctrl + Enter
3

(DataFrames) julia> x     # Typed into REPL
ERROR: UndefVarError: `x` not defined

I have a clone of the DataFrames package open.
image

I have activated the current directory environment.
image
image

I have chosen the DataFrames module as the active module with the VSCode GUI.
image

I have used the new REPL functionality to change the active module to DataFrames with Alt+m.
image

Related:

Feature Request: Lock Module · Issue #3024 · julia-vscode/julia-vscode (github.com)

I don´t really use control-Enter often, so I can’t say if that worked before or not, but I’m using 1.10 now and it seems to be working as you describe (x is defined in the REPL).

Yeah, I’m not experiencing this in 1.9.2 or 1.10.0-beta. ctrl+Enter is my primary way of coding, so very concerning that it could not work :exploding_head:

Fixed by https://github.com/julia-vscode/julia-vscode/pull/~3367.

Needs a new release though, which is building a I write this. Pre-release version 1.48.3 is out, so feel free to give that a go.

2 Likes

It is working after the update if I set both the VSCode and REPL module to the same thing.

julia> using DataFrames # Typed into REPL (automatically changed VSCode module to DataFrames)
[ Info: Precompiling DataFrames [a93c6f00-e57d-5684-b7b6-d8193f3e46c0]

julia> x # Typed into REPL (check not already defined)
ERROR: UndefVarError: `x` not defined

julia> x = 4 # Ctrl + Enter (define x)
4

julia> x # Typed into REPL (new definition still doesn't work)
ERROR: UndefVarError: `x` not defined

julia> DataFrames # Alt + m (change REPL module)

(DataFrames) julia> x # Typed into REPL (now defined variable exists)
4

Can you make the REPL module match the VSCode module automatically (even when the VSCode module hasn’t been manually selected)? I don’t understand why anyone would want these to be different.
image

I’m still pretty lost on how all these different switches go together and why. Sometimes the VSCode REPL behaves like I expect, but often it doesn’t, and it takes me a while to realize that the mistake is not in my code.

I just use the VSCode terminal and start Julia using a bash script with the correct parameters. Using the Julia console from the plug-in is confusing me too much.

I created a GitHub Issue for this here: