JuliaLang / Pkg.jl

Pkg - Package manager for the Julia programming language
https://pkgdocs.julialang.org
Other
621 stars 261 forks source link

REPL crashes when invalid command given in `pkg` mode #3787

Closed chrstphrbrns closed 7 months ago

chrstphrbrns commented 7 months ago
julia> VERSION
v"1.11.0-DEV.1547"

(@v1.11) pkg> a
ERROR: TaskFailedException
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base ./task.jl:944
...
vtjnash commented 7 months ago

For reference, the full error looks like this is a Pkg bug. There is a try/catch block on do_cmds, but it doesn't cover prepare_cmd

Unhandled Task ERROR: Pkg.Types.PkgError("`a` is not a recognized command. Type ? for help with available commands")
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Types.jl:68
  [2] (::Pkg.REPLMode.var"#13#14")(words::Vector{Pkg.REPLMode.QString})
    @ Pkg.REPLMode ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:285
  [3] iterate
    @ ./generator.jl:48 [inlined]
  [4] grow_to!(dest::Vector{Pkg.REPLMode.Statement}, itr::Base.Generator{Base.Iterators.Filter{ComposedFunction{typeof(!), typeof(isempty)}, Vector{Vector{Pkg.REPLMode.QString}}}, Pkg.REPLMode.var"#13#14"})
    @ Base ./array.jl:849
  [5] collect
    @ ./array.jl:773 [inlined]
  [6] map
    @ ./abstractarray.jl:3326 [inlined]
  [7] parse
    @ ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:282 [inlined]
  [8] prepare_cmd
    @ ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:378 [inlined]
  [9] do_cmds
    @ ~/julia/usr/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:87 [inlined]
 [10] (::REPLExt.var"#31#34"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ REPLExt ~/julia/usr/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:121
 [11] #invokelatest#2
    @ ./essentials.jl:1025 [inlined]
 [12] invokelatest
    @ ./essentials.jl:1022 [inlined]
 [13] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2734
 [14] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1410
 [15] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:458
ERROR: TaskFailedException
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base ./task.jl:944
  [2] wait()
    @ Base ./task.jl:1008
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base ./condition.jl:130
  [4] wait
    @ ./condition.jl:125 [inlined]
  [5] take_buffered(c::Channel{Any})
    @ Base ./channels.jl:493
  [6] take!
    @ ./channels.jl:487 [inlined]
  [7] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
    @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:315
  [8] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
    @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:305
  [9] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
    @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:461
 [10] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:447
 [11] (::Base.var"#1119#1121"{Bool, Symbol, Bool})(REPL::Module)
    @ Base ./client.jl:440
 [12] #invokelatest#2
    @ ./essentials.jl:1025 [inlined]
 [13] invokelatest
    @ ./essentials.jl:1022 [inlined]
 [14] run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
    @ Base ./client.jl:424
 [15] repl_main
    @ ./client.jl:561 [inlined]
 [16] _start()
    @ Base ./client.jl:535

    nested task error: `a` is not a recognized command. Type ? for help with available commands
    Stacktrace:
      [1] pkgerror(msg::String)
        @ Pkg.Types ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Types.jl:68
      [2] (::Pkg.REPLMode.var"#13#14")(words::Vector{Pkg.REPLMode.QString})
        @ Pkg.REPLMode ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:285
      [3] iterate
        @ ./generator.jl:48 [inlined]
      [4] grow_to!(dest::Vector{Pkg.REPLMode.Statement}, itr::Base.Generator{Base.Iterators.Filter{ComposedFunction{typeof(!), typeof(isempty)}, Vector{Vector{Pkg.REPLMode.QString}}}, Pkg.REPLMode.var"#13#14"})
        @ Base ./array.jl:849
      [5] collect
        @ ./array.jl:773 [inlined]
      [6] map
        @ ./abstractarray.jl:3326 [inlined]
      [7] parse
        @ ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:282 [inlined]
      [8] prepare_cmd
        @ ~/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:378 [inlined]
      [9] do_cmds
        @ ~/julia/usr/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:87 [inlined]
     [10] (::REPLExt.var"#31#34"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
        @ REPLExt ~/julia/usr/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:121
     [11] #invokelatest#2
        @ ./essentials.jl:1025 [inlined]
     [12] invokelatest
        @ ./essentials.jl:1022 [inlined]
     [13] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
        @ REPL.LineEdit ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2734
     [14] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
        @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1410
     [15] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
        @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:458