JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.61k stars 5.48k forks source link

Long stack traces when precompilation fails #50161

Open maleadt opened 1 year ago

maleadt commented 1 year ago

When a package, or any of its dependencies, fails to precompile, users are confronted with pretty long backtraces that aren't relevant to the actual failure, and just point to code loading:

ERROR: LoadError: Failed to precompile SparseArrays [2f01184e-e22b-5df5-ae63-d93ebab69eaf] to "/home/tim/Julia/depot/compiled/v1.10/SparseArrays/jl_XV0im5".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2396
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:2262 [inlined]
  [4] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1905
  [5] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1747
  [6] invoke_in_world(::UInt64, ::typeof(Base.__require_prelocked), ::Base.PkgId, ::String; kwargs::@Kwargs{})
    @ Base ./essentials.jl:898 [inlined]
  [7] invoke_in_world(::UInt64, ::typeof(Base.__require_prelocked), ::Base.PkgId, ::String)
    @ Base ./essentials.jl:895 [inlined]
  [8] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1738
  [9] macro expansion
    @ Base ./loading.jl:1725 [inlined]
 [10] macro expansion
    @ Base ./lock.jl:267 [inlined]
 [11] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1688
 [12] invoke_in_world(::UInt64, ::typeof(Base.__require), ::Module, ::Symbol; kwargs::@Kwargs{})
    @ Base ./essentials.jl:898 [inlined]
 [13] invoke_in_world(::UInt64, ::typeof(Base.__require), ::Module, ::Symbol)
    @ Base ./essentials.jl:895 [inlined]
 [14] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1681
 [15] include(mod::Module, _path::String)
    @ Base ./Base.jl:489 [inlined]
 [16] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{…}, dl_load_path::Vector{…}, load_path::Vector{…}, concrete_deps::Vector{…}, source::Nothing)
    @ Base ./loading.jl:2144
 [17] top-level scope
    @ stdin:3
Some type information was truncated. Use `show(err)` to see complete types.
in expression starting at /home/tim/Julia/depot/packages/KernelAbstractions/LVKmi/src/KernelAbstractions.jl:1
in expression starting at stdin:3

This has been worsened recently by #49525, but it's probably better to hide the stack trace altogether. cc @KristofferC

maleadt commented 1 year ago

Same with missing packages, these are not really useful backtraces:

julia> using Foo
ERROR: ArgumentError: Package Foo not found in current path.
- Run `import Pkg; Pkg.add("Foo")` to install the Foo package.
Stacktrace:
 [1] macro expansion
   @ Base ./loading.jl:1707 [inlined]
 [2] macro expansion
   @ Base ./lock.jl:267 [inlined]
 [3] __require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1688
 [4] invoke_in_world(::UInt64, ::typeof(Base.__require), ::Module, ::Symbol; kwargs::@Kwargs{})
   @ Base ./essentials.jl:898 [inlined]
 [5] invoke_in_world(::UInt64, ::typeof(Base.__require), ::Module, ::Symbol)
   @ Base ./essentials.jl:895 [inlined]
 [6] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1681

or

ERROR: LoadError: ArgumentError: Package TimerOutputs [a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

Stacktrace:
  [1] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1861
  [2] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1747
  [3] invoke_in_world(::UInt64, ::typeof(Base.__require_prelocked), ::Base.PkgId, ::String; kwargs::@Kwargs{})
    @ Base ./essentials.jl:898 [inlined]
  [4] invoke_in_world(::UInt64, ::typeof(Base.__require_prelocked), ::Base.PkgId, ::String)
    @ Base ./essentials.jl:895 [inlined]
  [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1738
  [6] macro expansion
    @ Base ./loading.jl:1725 [inlined]
  [7] macro expansion
    @ Base ./lock.jl:267 [inlined]
  [8] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1688
  [9] invoke_in_world(::UInt64, ::typeof(Base.__require), ::Module, ::Symbol; kwargs::@Kwargs{})
    @ Base ./essentials.jl:898 [inlined]
 [10] invoke_in_world(::UInt64, ::typeof(Base.__require), ::Module, ::Symbol)
    @ Base ./essentials.jl:895 [inlined]
 [11] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1681
KristofferC commented 1 year ago

Or (in VSCode)

ERROR: ArgumentError: Package Fooafdsa not found in current path.
- Run `import Pkg; Pkg.add("Fooafdsa")` to install the Fooafdsa package.
Stacktrace:
  [1] macro expansion
    @ ./loading.jl:1630 [inlined]
  [2] macro expansion
    @ ./lock.jl:267 [inlined]
  [3] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
  [4] eval
    @ ./boot.jl:370 [inlined]
  [5] eval
    @ ./Base.jl:68 [inlined]
  [6] repleval(m::Module, code::Expr, #unused#::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.47.2/scripts/packages/VSCodeServer/src/repl.jl:222
  [7] (::VSCodeServer.var"#107#109"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.47.2/scripts/packages/VSCodeServer/src/repl.jl:186
  [8] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:514
  [9] with_logger
    @ ./logging.jl:626 [inlined]
 [10] (::VSCodeServer.var"#106#108"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.47.2/scripts/packages/VSCodeServer/src/repl.jl:187
 [11] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [12] invokelatest(::Any)
    @ Base ./essentials.jl:813
 [13] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.47.2/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [14] (::VSCodeServer.var"#61#62")()
    @ VSCodeServer ./task.jl:514