SYSTEM (REPL): showing an error caused an error

Encountering a weird issue with Julia that seems to be something to do with some internal state as it persists between session restarts. This issue suddenly cropped up during a long running session, where states that were usually show-ing or display-ing no problem started throwing this weird REPL issue (included below).

Restarting Julia doesn’t help; the error persists. No clue as to what triggered this issue as previously my project’s structs were displaying just fine, and tests with simple structs have no issue being displayed in the REPL. Not only does this persist between sessions, I switched from 1.8.5 to 1.9 and the problem is still there!

The only thing I can think of is constant use of Revise.jl caused something in ~/.julia to be modified in an unhappy way, with this compounding error stream being the result, however I’m not sure what I should clear out from ~/.julia to get back to a clean slate (would prefer not to nuke everything).

Any advice would be appreciated!

julia> cam0
Error showing value of type ERROR: TypeError: in isdefined, expected Symbol, got a value of type Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}
Stacktrace:
  [1] make_typealias(x::Type)
    @ Base ./show.jl:610
  [2] show_typealias(io::IOContext{Base.TTY}, x::Type)
    @ Base ./show.jl:790
  [3] _show_type(io::IOContext{Base.TTY}, x::Type)
    @ Base ./show.jl:955
  [4] show(io::IOContext{Base.TTY}, x::Type)
    @ Base ./show.jl:950
  [5] print(io::IOContext{Base.TTY}, x::Type)
    @ Base ./strings/io.jl:35
  [6] print(::IOContext{Base.TTY}, ::String, ::Type, ::Vararg{Any})
    @ Base ./strings/io.jl:46
  [7] println(::IOContext{Base.TTY}, ::String, ::Type, ::Vararg{Any})
    @ Base ./strings/io.jl:75
  [8] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:310
  [9] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:287
 [10] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:557
 [11] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:285
 [12] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:899
 [13] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [14] invokelatest
    @ ./essentials.jl:813 [inlined]
 [15] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2647
 [16] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
 [17] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:514

caused by: TypeError: in isdefined, expected Symbol, got a value of type Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}
Stacktrace:
  [1] make_typealias(x::Type)
    @ Base ./show.jl:610
  [2] show_typealias(io::IOContext{Base.TTY}, x::Type)
    @ Base ./show.jl:790
  [3] _show_type(io::IOContext{Base.TTY}, x::Type)
    @ Base ./show.jl:955
  [4] show(io::IOContext{Base.TTY}, x::Type)
    @ Base ./show.jl:950
  [5] _show_default(io::IOContext{Base.TTY}, x::Any)
    @ Base ./show.jl:463
  [6] show_default
    @ ./show.jl:459 [inlined]
  [7] show
    @ ./show.jl:454 [inlined]
  [8] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::
SYSTEM (REPL): showing an error caused an error
ERROR: TypeError: in isdefined, expected Symbol, got a value of type Core.Compiler.IdDict{Core.Compiler.InferenceState, Nothing}
Stacktrace:
  [1] make_typealias(x::Type)
    @ Base ./show.jl:610
  [2] show_typealias(io::IOContext{IOBuffer}, x::Type)
    @ Base ./show.jl:790
  [3] _show_type(io::IOContext{IOBuffer}, x::Type)
    @ Base ./show.jl:955
  [4] show(io::IOContext{IOBuffer}, x::Type)
    @ Base ./show.jl:950
  [5] sprint(f::Function, args::Type; context::IOContext{Base.TTY}, sizehint::Int64)
    @ Base ./strings/io.jl:112
  [6] sprint
    @ ./strings/io.jl:107 [inlined]
  [7] #print_type_bicolor#540
    @ ./show.jl:2491 [inlined]
  [8] show_tuple_as_call(io::IOContext{Base.TTY}, name::Symbol, sig::Type; demangle::Bool, kwargs::Nothing, argnames::Vector{Symbol}, qualified::Bool, hasfirst::Bool)
    @ Base ./show.jl:2472
  [9] show_tuple_as_call
    @ ./show.jl:2441 [inlined]
 [10] show_spec_linfo(io::IOContext{Base.TTY}, frame::Base.StackTraces.StackFrame)
    @ Base.StackTraces ./stacktraces.jl:244
 [11] print_stackframe(io::IOContext{Base.TTY}, i::Int64, frame::Base.StackTraces.StackFrame, n::Int64, ndigits_max::Int64, modulecolor::Symbol)
    @ Base ./errorshow.jl:730
 [12] print_stackframe(io::IOContext{Base.TTY}, i::Int64, frame::Base.StackTraces.StackFrame, n::Int64, ndigits_max::Int64, modulecolordict::IdDict{Module, Symbol}, modulecolorcycler::Base.Iterators.Stateful{Base.Iterators.Cycle{Vector{Symbol}}, Union{Nothing, Tuple{Symbol, Int64}}, Int64})
    @ Base ./errorshow.jl:695
 [13] show_full_backtrace(io::IOContext{Base.TTY}, trace::Vector{Any}; print_linebreaks::Bool)
    @ Base ./errorshow.jl:594
 [14] show_full_backtrace
    @ ./errorshow.jl:587 [inlined]
 [15] show_backtrace(io::IOContext{Base.TTY}, t::Vector{Base.StackTraces.StackFrame})
    @ Base ./errorshow.jl:791
 [16] showerror(io::IOContext{Base.TTY}, ex::TypeError, bt::Vector{Base.StackTraces.StackFrame}; backtrace::Bool)
    @ Base ./errorshow.jl:90
 [17] show_exception_stack(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
    @ Base ./errorshow.jl:895
 [18] display_error(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
    @ Base ./client.jl:111
 [19] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [20] invokelatest
    @ ./essentials.jl:813 [inlined]
 [21] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:300
 [22] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:287
 [23] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:557
 [24] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:285
 [25] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:899
 [26] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [27] invokelatest
    @ ./essentials.jl:813 [inlined]
 [28] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2647
 [29] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
 [30] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:514

How did you install julia on your system? And what type of machine are you using?

Also, do you have anything going on in your startup.jl beyond instantiating Revise.jl?

Julia was just downloaded as a tarball and extracted, with JULIA_BINDIR set and the binary’s directly placed in PATH on an Ubuntu 22.04 install.

No custom startup.jl is used, and this error shows up whether I using Revise or not.

This error, or something related, can be reproduced when I load up my current project, as in include all the appropriate files and loads up modules and packages, etc.

If I don’t include my project, everything shakes out appropriately

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

help?> cam0
search: clamp clamp!

Couldn't find cam0
Perhaps you meant clamp, cat, cmp, clamp!, catch, hcat, vcat, ccall, Cmd, cbrt, cd, ceil, chmod, chomp, chop, cis, cld, conj, copy, cos, cosc, cosd, cosh, cot, cotd, coth, cp, csc or cscd
  No documentation found.

  Binding cam0 does not exist.

Including my project borks things up in weird ways, even without using Revise.jl

julia> include("src/str.jl")
doGN (generic function with 2 methods)

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

help?> cam0
search:ERROR: Base.InvalidCharError{Char}('\x83')
Stacktrace:
  [1] throw_invalid_char(c::Char)
    @ Base ./char.jl:86
  [2] UInt32
    @ ./char.jl:133 [inlined]
  [3] convert
    @ ./char.jl:185 [inlined]
  [4] cconvert
    @ ./essentials.jl:492 [inlined]
  [5] lowercase(c::Char)
    @ Base.Unicode ./strings/unicode.jl:289
  [6] matchinds(needle::String, haystack::String; acronym::Bool)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:606
  [7] matchinds
    @ ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:597 [inlined]
  [8] bestmatch
    @ ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:618 [inlined]
  [9] fuzzyscore(needle::String, haystack::String)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:628
 [10] #19
    @ ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:637 [inlined]
 [11] iterate
    @ ./generator.jl:47 [inlined]
 [12] collect_to!(dest::Vector{Tuple{Float64, Float64}}, itr::Base.Generator{Vector{String}, REPL.var"#19#20"{String}}, offs::Int64, st::Int64)
    @ Base ./array.jl:840
 [13] collect_to_with_first!
    @ ./array.jl:818 [inlined]
 [14] _collect(c::Vector{String}, itr::Base.Generator{Vector{String}, REPL.var"#19#20"{String}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:812
 [15] collect_similar
    @ ./array.jl:711 [inlined]
 [16] map
    @ ./abstractarray.jl:3261 [inlined]
 [17] fuzzysort(search::String, candidates::Vector{String})
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:637
 [18] doc_completions(name::String, mod::Module)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:734
 [19] repl_search(io::Base.TTY, s::String, mod::Module)
    @ REPL ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:380
 [20] top-level scope
    @ ~/Downloads/julia-1.9.0/share/julia/stdlib/v1.9/REPL/src/docview.jl:477

Seems like nuking .julia may be required here, but that seems heavy handed. If anyone has advice on how to delete the .julia config files associated with just this project / package environment, then that would be more targeted.

Could it be that you copied-pasted some code from the web into src/str.jl which contains invalid characters?

Another guess would be that src/str.jl does type piracy on any of show, print and friends and that causes hick-ups, even between different julia versions.

Can you post your code from src/str.jl?
Or does the issues also appear when you include any other code?

1 Like

The InvalidCharError shows up when other code is included. I isolated a line in a file that causes the “InvalidCharError” that was merely global bestT = bestT2

Deleting that line, or deleting the chars global allows the “InvalidCharError” to go away when the whole file is loaded. Using “global” elsewhere in the file doesn’t cause the InvalidCharError. Moving / rewriting that global bestT = bestT2 line to somewhere causes the error again, but other lines using the term global doesn’t trigger an InvalidCharError.

If I include the file with the bad lines, then delete the lines and re-include, the error persists. Very, very strange – no actually illegal characters, as far as I can tell, and whatever is triggering the issue persists even if the lines that trigger the issue are removed.

In other words, I don’t think the problem is the InvalidCharError, but whatever is causing the larger issue with the REPL or whatever itself. No type-piracy within the project; definitely nothing of the sort between when the issue didn’t crop up and when it did.

The src/str.jl file is a bit to cumbersome to share as it’s janky research code for now, but happy to try and produce a smaller MRP if there’s a useful direction to go in.

TBH, I am also a bit clueless about what is causing the problem.

… but happy to try and produce a smaller MRP if there’s a useful direction to go in.

Probably can only increase the chances of fixing the problem.

I am wondering whether the faulty statement global bestT = bestT2 is located right before or after a (doc) string definition and its maybe that part that is causing the problem? This theory is based on the stack trace containing top level calls that seem to go down the doc string handling route …

Commenting out those offending lines has actually alleviated the wider problem, weirdly enough.

Those lines would trigger the issue even if I moved them up or down a few lines, but commented out (so still partially parsed) doesn’t trigger any issues.

It’s definitely strange since I can comment out the original lines, but freshly typing out those lines elsewhere (not copied) triggers the issue again – so it’s not some InvalidChar thing as far as I can tell, but have no clue as to what triggers the issue.

If I encounter it again, I’ll try to drill down some more, but i’ll leave this post as a reference in case others run into similar errors with the REPL.