ConcurrencyViolationError when loading packages via Requires.jl in julia 1.11

I have a package (not public, not registered) that loads ForwardDiff.jl and NonhomotheticCES.jl, which defines an extension for the former via Requires.jl. In Julia 1.11, I started getting the following error:

  1 dependency successfully precompiled in 5 seconds. 296 already precompiled.
┌ Warning: Error requiring `ForwardDiff` from `NonhomotheticCES`
│   exception =
│    ConcurrencyViolationError("deadlock detected in loading NonhomotheticCES -> NonhomotheticCES && SectorHumanCapital")
│    Stacktrace:
│      [1] start_loading(modkey::Base.PkgId, build_id::UInt128, stalecheck::Bool)
│        @ Base ./loading.jl:2058
│      [2] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│        @ Base ./loading.jl:2310
│      [3] #invoke_in_world#3
│        @ ./essentials.jl:1089 [inlined]
│      [4] invoke_in_world
│        @ ./essentials.jl:1086 [inlined]
│      [5] _require_prelocked
│        @ ./loading.jl:2302 [inlined]
│      [6] macro expansion
│        @ ./loading.jl:2241 [inlined]
│      [7] macro expansion
│        @ ./lock.jl:273 [inlined]
│      [8] __require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:2198
│      [9] #invoke_in_world#3
│        @ ./essentials.jl:1089 [inlined]
│     [10] invoke_in_world
│        @ ./essentials.jl:1086 [inlined]
│     [11] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:2191
│     [12] top-level scope
│        @ ~/.julia/packages/NonhomotheticCES/ydDVQ/src/NonhomotheticCES.jl:89
│     [13] eval
│        @ ./boot.jl:430 [inlined]
│     [14] eval
│        @ ~/.julia/packages/NonhomotheticCES/ydDVQ/src/NonhomotheticCES.jl:4 [inlined]
│     [15] (::NonhomotheticCES.var"#6#9")()
│        @ NonhomotheticCES ~/.julia/packages/Requires/Z8rfN/src/require.jl:101
│     [16] macro expansion
│        @ timing.jl:421 [inlined]
│     [17] err(f::Any, listener::Module, modname::String, file::String, line::Any)
│        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:47
│     [18] (::NonhomotheticCES.var"#5#8")()
│        @ NonhomotheticCES ~/.julia/packages/Requires/Z8rfN/src/require.jl:100
│     [19] withpath(f::Any, path::String)
│        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:37
│     [20] (::NonhomotheticCES.var"#4#7")()
│        @ NonhomotheticCES ~/.julia/packages/Requires/Z8rfN/src/require.jl:99
│     [21] listenpkg(f::Any, pkg::Base.PkgId)
│        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:20
│     [22] macro expansion
│        @ ~/.julia/packages/Requires/Z8rfN/src/require.jl:98 [inlined]
│     [23] __init__()
│        @ NonhomotheticCES ~/.julia/packages/NonhomotheticCES/ydDVQ/src/NonhomotheticCES.jl:87
│     [24] run_module_init(mod::Module, i::Int64)
│        @ Base ./loading.jl:1336
│     [25] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
│        @ Base ./loading.jl:1324
│     [26] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
│        @ Base ./loading.jl:1213
│     [27] _include_from_serialized (repeats 2 times)
│        @ ./loading.jl:1169 [inlined]
│     [28] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
│        @ Base ./loading.jl:1969
│     [29] _require(pkg::Base.PkgId, env::String)
│        @ Base ./loading.jl:2450
│     [30] __require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:2315
│     [31] #invoke_in_world#3
│        @ ./essentials.jl:1089 [inlined]
│     [32] invoke_in_world
│        @ ./essentials.jl:1086 [inlined]
│     [33] _require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:2302
│     [34] macro expansion
│        @ ./loading.jl:2241 [inlined]
│     [35] macro expansion
│        @ ./lock.jl:273 [inlined]
│     [36] __require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:2198
│     [37] #invoke_in_world#3
│        @ ./essentials.jl:1089 [inlined]
│     [38] invoke_in_world
│        @ ./essentials.jl:1086 [inlined]
│     [39] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:2191
│     [40] eval
│        @ ./boot.jl:430 [inlined]
│     [41] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
│        @ REPL ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:245
│     [42] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
│        @ REPL ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:342
│     [43] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
│        @ REPL ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:327
│     [44] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
│        @ REPL ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:483
│     [45] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:469
│     [46] (::Base.var"#1139#1141"{Bool, Symbol, Bool})(REPL::Module)
│        @ Base ./client.jl:446
│     [47] #invokelatest#2
│        @ ./essentials.jl:1055 [inlined]
│     [48] invokelatest
│        @ ./essentials.jl:1052 [inlined]
│     [49] run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:430
│     [50] repl_main
│        @ ./client.jl:567 [inlined]
└ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:51

I do understand that package extensions are preferable, and I update the package accordingly, but nevertheless I am wondering if this is a bug, and if yes, in what package I should report it, and if there is a simple workaround.

That is right: you cannot import your own package into yourself anymore (why would you ever want to do that?), so this is not supported, and seems really not very useful either:

module A
    __init__() = @eval using A: __init__
end
3 Likes

Thanks. A more informative error message would be helpful, though.