What is the proper way to use Julia Jupyter notebooks in VS Code?

I tried to setup Jupyter with Julia recently, but I’ve never arrived at a perfect solution. See below for information about what I tried and what didn’t work. My questions are:

  1. What Julia packages should I add to my project? (e.g. IJulia?)
  2. What VS Code extensions do I need installed? (e.g. Julia (insiders?), Jupyter)
  3. Which kernel should I use? (the one from Jupyter, the one from Julia extension…). Mind you, when using the one from Julia, the error messages were messed up.
  4. What other things do I need to do to have proper LSP support, formatting, etc? Notably, I’d liek to have cross-cell autocompletion and documentation. (e.g. use VS Code insiders, select specific kernels to run the ipynb files)

What I found:

  • The Jupyter extension by itself doesn’t provide any Julia LSP features like docs (understandably)
  • The Julia extension by itself seems to work, but I need to select a kernel coming from my global installation of Julia, not the one installed by the extension, otherwise the errors are messed up.
  • I haven’t found a way to get a function defined in one cell to be autocompleted in some other cell. Similarly, docs for my functions don’t show unless I’m writing in the cell where the functions are defined. Hopefully this is solvable.
  1. None
  2. Just the Julia extension.
  3. The one from the Julia extension. What does “the error messages were messed up” mean?
  4. Nothing, that’s just not properly implemented yet (each cell is treated as its own, indeptendent, document atm, but there are plans to change that, of course).

Thanks, this is very simple indeed.

Each cell is treated as its own, indeptendent, document atm, but there are plans to change that, of course.

Is there an issue I could watch to track this?

What does “the error messages were messed up” mean?

For example, running sqrt(-1) in the Jupyter kernel gives me:

DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).

Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64)
   @ Base.Math ./math.jl:33
 [2] sqrt
   @ ./math.jl:582 [inlined]
 [3] sqrt(x::Int64)
   @ Base.Math ./math.jl:608
 [4] top-level scope
   @ In[1]:1
 [5] eval
   @ ./boot.jl:360 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1094

While running it in the Julia kernel fails with this error message:

Stacktrace:
  [1] throw_complex_domainerror(f::Symbol, x::Float64)
    @ Base.Math ./math.jl:33
  [2] sqrt
    @ ./math.jl:582 [inlined]
  [3] sqrt(x::Int64)
    @ Base.Math ./math.jl:608
  [4] top-level scope
    @ ~/code/ai-mgr-1/evolutionary-algorithms/eva/test.ipynb:1
  [5] eval
    @ ./boot.jl:360 [inlined]
  [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1094
  [7] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [8] invokelatest
    @ ./essentials.jl:706 [inlined]
  [9] (::VSCodeServer.var"#98#99"{VSCodeServer.NotebookRunCellArguments, String})()
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/serve_notebook.jl:18
 [10] withpath(f::VSCodeServer.var"#98#99"{VSCodeServer.NotebookRunCellArguments, String}, path::String)
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:185
 [11] notebook_runcell_request(conn::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::VSCodeServer.NotebookRunCellArguments)
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/serve_notebook.jl:14
 [12] dispatch_msg(x::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeServer.JSONRPC.MsgDispatcher, msg::Dict{String, Any})
    @ VSCodeServer.JSONRPC ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/JSONRPC/src/typed.jl:67
 [13] serve_notebook(pipename::String; crashreporting_pipename::String)
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/serve_notebook.jl:94
 [14] top-level scope
    @ ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/notebook/notebook.jl:10
 [15] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
 [16] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:285
 [17] _start()
    @ Base ./client.jl:485