Skip to content

Commit 4d2ed32

Browse files
fix require_stdlib fast path for loaded exts
1 parent 94a0ee8 commit 4d2ed32

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

base/loading.jl

+17-16
Original file line numberDiff line numberDiff line change
@@ -2501,51 +2501,52 @@ function _require_from_serialized(uuidkey::PkgId, path::String, ocachepath::Unio
25012501
end
25022502

25032503
# load a serialized file directly from append_bundled_depot_path for uuidkey without stalechecks
2504-
function require_stdlib(uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
2504+
function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
25052505
@lock require_lock begin
2506-
if root_module_exists(uuidkey)
2507-
return loaded_modules[uuidkey]
2506+
# the PkgId of the ext, or package if not an ext
2507+
this_uuidkey = ext isa String ? PkgId(uuid5(package_uuidkey.uuid, ext), ext) : package_uuidkey
2508+
if root_module_exists(this_uuidkey)
2509+
return loaded_modules[this_uuidkey]
25082510
end
25092511
# first since this is a stdlib, try to look there directly first
25102512
env = Sys.STDLIB
25112513
#sourcepath = ""
25122514
if ext === nothing
2513-
sourcepath = normpath(env, uuidkey.name, "src", uuidkey.name * ".jl")
2515+
sourcepath = normpath(env, this_uuidkey.name, "src", this_uuidkey.name * ".jl")
25142516
else
2515-
sourcepath = find_ext_path(normpath(joinpath(env, uuidkey.name)), ext)
2516-
uuidkey = PkgId(uuid5(uuidkey.uuid, ext), ext)
2517+
sourcepath = find_ext_path(normpath(joinpath(env, package_uuidkey.name)), ext)
25172518
end
2518-
#mbypath = manifest_uuid_path(env, uuidkey)
2519+
#mbypath = manifest_uuid_path(env, this_uuidkey)
25192520
#if mbypath isa String && isfile_casesensitive(mbypath)
25202521
# sourcepath = mbypath
25212522
#else
25222523
# # if the user deleted the stdlib folder, we next try using their environment
2523-
# sourcepath = locate_package_env(uuidkey)
2524+
# sourcepath = locate_package_env(this_uuidkey)
25242525
# if sourcepath !== nothing
25252526
# sourcepath, env = sourcepath
25262527
# end
25272528
#end
25282529
#if sourcepath === nothing
25292530
# throw(ArgumentError("""
2530-
# Package $(repr("text/plain", uuidkey)) is required but does not seem to be installed.
2531+
# Package $(repr("text/plain", this_uuidkey)) is required but does not seem to be installed.
25312532
# """))
25322533
#end
2533-
set_pkgorigin_version_path(uuidkey, sourcepath)
2534+
set_pkgorigin_version_path(this_uuidkey, sourcepath)
25342535
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH))
2535-
newm = start_loading(uuidkey)
2536+
newm = start_loading(this_uuidkey)
25362537
newm === nothing || return newm
25372538
try
2538-
newm = _require_search_from_serialized(uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
2539+
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
25392540
finally
2540-
end_loading(uuidkey, newm)
2541+
end_loading(this_uuidkey, newm)
25412542
end
25422543
if newm isa Module
25432544
# After successfully loading, notify downstream consumers
2544-
insert_extension_triggers(env, uuidkey)
2545-
run_package_callbacks(uuidkey)
2545+
insert_extension_triggers(env, this_uuidkey)
2546+
run_package_callbacks(this_uuidkey)
25462547
else
25472548
# if the user deleted their bundled depot, next try to load it completely normally
2548-
newm = _require_prelocked(uuidkey)
2549+
newm = _require_prelocked(this_uuidkey)
25492550
end
25502551
return newm
25512552
end

0 commit comments

Comments
 (0)