Excessively long error messages

I am using Julia in VS Code. Typically, I run my main.jl file through the “Run in REPL” button or “Run as new process”. However, if there is any typing error, my terminal gets cluttered each time with an overly long error/waring message, which I do not fully understand. Basically, in my example, there is a typing error in one of my functions, which goes away completely when i fix the error. Therefore I do not understand why I get the world age error, it seems to be triggered when there is ANY error in ANY function. Since I close the terminal with the trash icon in VS code before running the script again, I should not even get the world age error/warning in the first place.

Can we somehow deactivate the message or at least keep it extremely short, so that I do not have to scroll all the way up each time in my terminal to find the actually important error message? Here is an example:

ERROR: UndefVarError: ax0 not defined in Main
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] WARNING: Detected access to binding Main.dostuff! in a world prior to its definition world.
Julia 1.12 has introduced more strict world age semantics for global bindings.
!!! This code may malfunction under Revise.
!!! This code will error in future versions of Julia.
Hint: Add an appropriate invokelatest around the access to this binding.
To make this warning an error, and hence obtain a stack trace, use julia --depwarn=error.
dostuff!(test::Base.RefValue{Test}, control::Base.RefValue{Control})
@ Main ~/Desktop/Julia/X/helper.jl:38
[2] WARNING: Detected access to binding Main.go! in a world prior to its definition world.
Julia 1.12 has introduced more strict world age semantics for global bindings.
!!! This code may malfunction under Revise.
!!! This code will error in future versions of Julia.
Hint: Add an appropriate invokelatest around the access to this binding.
To make this warning an error, and hence obtain a stack trace, use julia --depwarn=error.
go!(opt::Options, net::Flux.Chain{…}, num::Flux.Chain{…}, mat::Matrix{…}, prop::@NamedTuple{…}, netB::@NamedTuple{…}, propB::Optimisers.Leaf{…})
@ Main ~/Desktop/Julia/X/go.jl:107
[3] WARNING: Detected access to binding Main.main in a world prior to its definition world.
Julia 1.12 has introduced more strict world age semantics for global bindings.
!!! This code may malfunction under Revise.
!!! This code will error in future versions of Julia.
Hint: Add an appropriate invokelatest around the access to this binding.
To make this warning an error, and hence obtain a stack trace, use julia --depwarn=error.
main()
@ Main ~/Desktop/Julia/main/main.jl:104
[4] top-level scope
@ ~/Desktop/Julia/main/main.jl:107
Some type information was truncated. Use show(err) to see complete types.

julia>

Without the code it’s hard to say, but it appears that something is referencing ax0 in the right side of an expression like

...
y = ax0
...

without having defined it first.

There also appears to be a mention of a dostuff! function before it was defined.

You might want to paste the code between triple back ticks like this.

```julia

your code here

```

I know. This question is not about the specific error. When I fix the typing error all error messages and warnings disappear. But when there is ANY error, my terminal gets cluttered with the world age error messages all the time.

Very weird, can you post a minimum working example?

Yes, here is a minimal working example:

maintest.jl:
include(“test.jl”)
test()

test.jl:
function test()
pridnt(“Hello”)
end

There is a typing error. Here is the excessively long error message including the weird and way too long world age error:

Activating project at ~/.julia/environments/v1.13
ERROR: LoadError: UndefVarError: pridnt not defined in Main
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] WARNING: Detected access to binding Main.test in a world prior to its definition world.
Julia 1.12 has introduced more strict world age semantics for global bindings.
!!! This code may malfunction under Revise.
!!! This code will error in future versions of Julia.
Hint: Add an appropriate invokelatest around the access to this binding.
To make this warning an error, and hence obtain a stack trace, use julia --depwarn=error.
test()
@ Main ~/Desktop/Julia/main/test.jl:2
[2] top-level scope
@ ~/Desktop/Julia/main/maintest.jl:3
[3] include(mapexpr::Function, mod::Module, _path::String)
@ Base ./Base.jl:310
[4] run(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, error_handler::VSCodeDebugger.var"#startdebugger##0#startdebugger##1"{String})
@ VSCodeDebugger.DebugAdapter ~/.vscode/extensions/julialang.language-julia-1.250.2/scripts/packages/DebugAdapter/src/packagedef.jl:123
[5] startdebugger()
@ VSCodeDebugger ~/.vscode/extensions/julialang.language-julia-1.250.2/scripts/packages/VSCodeDebugger/src/VSCodeDebugger.jl:102
[6] top-level scope
@ ~/.vscode/extensions/julialang.language-julia-1.250.2/scripts/debugger/run_debugger.jl:12
[7] include(mod::Module, _path::String)
@ Base ./Base.jl:309
[8] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:344
[9] _start()
@ Base ./client.jl:577

Interesting, when i use julia maintest.jl i get:

ERROR: LoadError: UndefVarError: `pridnt` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] test()
   @ Main ~/Desktop/test.jl:2
 [2] top-level scope
   @ ~/Desktop/maintest.jl:2
 [3] include(mod::Module, _path::String)
   @ Base ./Base.jl:309
 [4] exec_options(opts::Base.JLOptions)
   @ Base ./client.jl:344
 [5] _start()
   @ Base ./client.jl:577
in expression starting at ~/Desktop/maintest.jl:2

When i run it via vscode i get:

ERROR: UndefVarError: `pridnt` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] WARNING: Detected access to binding `Main.test` in a world prior to its definition world.
  Julia 1.12 has introduced more strict world age semantics for global bindings.
  !!! This code may malfunction under Revise.
  !!! This code will error in future versions of Julia.
Hint: Add an appropriate `invokelatest` around the access to this binding.
To make this warning an error, and hence obtain a stack trace, use `julia --depwarn=error`.
test()
   @ Main ~/Desktop/test.jl:2
 [2] top-level scope
   @ ~/Desktop/maintest.jl:2

Do you have Revise.jl installed? I’m not sure how to help from here.

I don’t know what Revise.jl is. I looked it up. No, I dont use it. I use Julia without any modification. With “julia maintest.jl” do you run this by hand in the terminal? I use Julia only through VS code exactly as I would use matlab by hitting the run button.

Ahh that explains it. I think the run button will actually run the debugger, which explains the verbosity. I used the keybind to run a block, which for me is ctrl + enter or shift + enter.

Typically you want to run it this way, as that’s an interactive mode, whereas the debug mode will be much slower and be non-interactive. Running it from the terminal is non-interactive as well, the debug button runs it like i did first but with the debug flag.

I tell all new students not to use any VSCode button, but just use:

include("maintest.jl")

in the REPL or whatever the name of your script is to execute a script.

From my point of view, using the VSCode magic only makes it harder to debug errors.

I use either the first or second selection in the screenshot. Also I always terminate the terminal/REPL with the trash icon in VS code to avoid issues with existing variables.

Also I completely avoid to using any debug mode as Julia has a bug where breakpoints cannot be removed during debugging, which I did post a while ago here as well. This makes debugging code with breakpoints impossible. Hence, I just run the code and use print() commands to somehow get my code working.

Try highlighting the code you want to run and use the keyboard shortcuts. It should work better, the VSCode ui can be a bit finicky with the julia extension, given how active development on julia and its extension are.