Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2694,6 +2694,7 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}, fro
return newm
end
env = Sys.STDLIB
loading_started = false
try
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH))
from_stdlib = true # set to false if `from` is a normal package so we do not want the internal loader for the extension either
Expand All @@ -2718,10 +2719,11 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}, fro
set_pkgorigin_version_path(this_uuidkey, sourcepath)
newm = start_loading(this_uuidkey, UInt128(0), true)
newm === nothing || return newm
loading_started = true
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
end
finally
end_loading(this_uuidkey, newm)
loading_started && end_loading(this_uuidkey, newm)
end
if newm isa Module
# After successfully loading, notify downstream consumers
Expand Down
19 changes: 19 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1639,3 +1639,22 @@ end
end
end
end
@testset "require_stdlib extension with non-stdlib from module" begin
# Test that require_stdlib doesn't error when called with an extension
# and the `from` module is not from the bundled depot (from_stdlib=false path)
# This is a regression test for https://github.com/JuliaLang/julia/issues/60392
cmd = `$(Base.julia_cmd()) --startup-file=no -e '
Pkg_pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
REPLExt_pkgid = Base.PkgId(Base.uuid5(Pkg_pkgid.uuid, "REPLExt"), "REPLExt")
# Create and register a fake REPL module to simulate a non-stdlib module being loaded
# This triggers the from_stdlib=false path since the fake module is not from the bundled depot
FakeREPL = Module(:REPL)
FakeREPL_pkgid = Base.PkgId(Base.UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL")
Base.register_root_module(FakeREPL)
# This should not throw a KeyError from end_loading
Base.require_stdlib(Pkg_pkgid, "REPLExt", FakeREPL)
# Verify the extension was loaded
Base.maybe_root_module(REPLExt_pkgid) isa Module || error("Something is wrong")
'`
@test success(cmd)
end