Requires.jl
Requires.jl copied to clipboard
Error when running Julia with `--compiled-modules=no`
I ran into an error when running Julia with --compiled-modules=no
and importing OrdinaryDiffEq
. Narrowing it down, the error appears to occur when importing LoopVectorization
followed by ForwardDiff
, where the @require ForwardDiff
in the LoopVectorization
code fails with an UndefVarError
that does not occur if compiled modules are activated or the order of importing is reversed.
I’ve first reported the issue as https://github.com/JuliaSIMD/LoopVectorization.jl/issues/268 but they suspected that it’s a problem with Requires
.
This is a minimal reproducer:
module TestRepo
using Requires
function __init__()
@require ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" begin
@require ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" using .ForwardDiff: Dual
end
end
end
Then starting Julia with --compiled-modules=no
and running:
julia> using TestRepo
julia> using ForwardDiff
┌ Warning: Error requiring `ForwardDiff` from `TestRepo`
│ exception =
│ UndefVarError: Dual not defined
│ Stacktrace:
│ [1] top-level scope
│ @ none:1
│ [2] eval
│ @ ./boot.jl:360 [inlined]
│ [3] eval
│ @ ~/.julia/dev/TestRepo/src/TestRepo.jl:1 [inlined]
│ [4] (::TestRepo.var"#9#12")()
│ @ TestRepo ~/.julia/packages/Requires/7Ncym/src/require.jl:99
│ [5] err(f::Any, listener::Module, modname::String)
│ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:47
│ [6] (::TestRepo.var"#8#11")()
│ @ TestRepo ~/.julia/packages/Requires/7Ncym/src/require.jl:98
│ [7] withpath(f::Any, path::String)
│ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:37
│ [8] (::TestRepo.var"#7#10")()
│ @ TestRepo ~/.julia/packages/Requires/7Ncym/src/require.jl:97
│ [9] listenpkg(f::Any, pkg::Base.PkgId)
│ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:20
│ [10] macro expansion
│ @ ~/.julia/packages/Requires/7Ncym/src/require.jl:95 [inlined]
│ [11] top-level scope
│ @ ~/.julia/dev/TestRepo/src/TestRepo.jl:7
│ [12] eval
│ @ ./boot.jl:360 [inlined]
│ [13] eval
│ @ ~/.julia/dev/TestRepo/src/TestRepo.jl:1 [inlined]
│ [14] (::TestRepo.var"#3#6")()
│ @ TestRepo ~/.julia/packages/Requires/7Ncym/src/require.jl:99
│ [15] err(f::Any, listener::Module, modname::String)
│ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:47
│ [16] (::TestRepo.var"#2#5")()
│ @ TestRepo ~/.julia/packages/Requires/7Ncym/src/require.jl:98
│ [17] withpath(f::Any, path::String)
│ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:37
│ [18] (::TestRepo.var"#1#4")()
│ @ TestRepo ~/.julia/packages/Requires/7Ncym/src/require.jl:97
│ [19] #invokelatest#2
│ @ ./essentials.jl:708 [inlined]
│ [20] invokelatest
│ @ ./essentials.jl:706 [inlined]
│ [21] foreach(f::typeof(Base.invokelatest), itr::Vector{Function})
│ @ Base ./abstractarray.jl:2141
│ [22] loadpkg(pkg::Base.PkgId)
│ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:27
│ [23] #invokelatest#2
│ @ ./essentials.jl:708 [inlined]
│ [24] invokelatest
│ @ ./essentials.jl:706 [inlined]
│ [25] require(uuidkey::Base.PkgId)
│ @ Base ./loading.jl:920
│ [26] require(into::Module, mod::Symbol)
│ @ Base ./loading.jl:901
│ [27] include
│ @ ./Base.jl:386 [inlined]
│ [28] _require(pkg::Base.PkgId)
│ @ Base ./loading.jl:1050
│ [29] require(uuidkey::Base.PkgId)
│ @ Base ./loading.jl:914
│ [30] require(into::Module, mod::Symbol)
│ @ Base ./loading.jl:901
│ [31] include
│ @ ./Base.jl:386 [inlined]
│ [32] _require(pkg::Base.PkgId)
│ @ Base ./loading.jl:1050
│ [33] require(uuidkey::Base.PkgId)
│ @ Base ./loading.jl:914
│ [34] require(into::Module, mod::Symbol)
│ @ Base ./loading.jl:901
│ [35] eval
│ @ ./boot.jl:360 [inlined]
│ [36] eval_user_input(ast::Any, backend::REPL.REPLBackend)
│ @ REPL ~/Documents/languages/julia-polly/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
│ [37] repl_backend_loop(backend::REPL.REPLBackend)
│ @ REPL ~/Documents/languages/julia-polly/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
│ [38] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
│ @ REPL ~/Documents/languages/julia-polly/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
│ [39] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
│ @ REPL ~/Documents/languages/julia-polly/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
│ [40] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│ @ REPL ~/Documents/languages/julia-polly/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
│ [41] (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
│ @ Base ./client.jl:387
│ [42] #invokelatest#2
│ @ ./essentials.jl:708 [inlined]
│ [43] invokelatest
│ @ ./essentials.jl:706 [inlined]
│ [44] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│ @ Base ./client.jl:372
│ [45] exec_options(opts::Base.JLOptions)
│ @ Base ./client.jl:302
│ [46] _start()
│ @ Base ./client.jl:485
└ @ Requires ~/.julia/packages/Requires/7Ncym/src/require.jl:49
throws the error.
If we remove the outer @requires
, it works without an error.