Skip to content

Commit 63b66b8

Browse files
IanButterworthKristofferC
authored andcommitted
Fix uuidkey of exts in fast path of require_stdlib (#54730)
The wrong uuid was being used for the fast path for exts (cherry picked from commit 1b6ec0d)
1 parent 9874d82 commit 63b66b8

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

base/loading.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,51 +2453,52 @@ function _require_from_serialized(uuidkey::PkgId, path::String, ocachepath::Unio
24532453
end
24542454

24552455
# load a serialized file directly from append_bundled_depot_path for uuidkey without stalechecks
2456-
function require_stdlib(uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
2456+
function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
24572457
@lock require_lock begin
2458-
if root_module_exists(uuidkey)
2459-
return loaded_modules[uuidkey]
2458+
# the PkgId of the ext, or package if not an ext
2459+
this_uuidkey = ext isa String ? PkgId(uuid5(package_uuidkey.uuid, ext), ext) : package_uuidkey
2460+
if root_module_exists(this_uuidkey)
2461+
return loaded_modules[this_uuidkey]
24602462
end
24612463
# first since this is a stdlib, try to look there directly first
24622464
env = Sys.STDLIB
24632465
#sourcepath = ""
24642466
if ext === nothing
2465-
sourcepath = normpath(env, uuidkey.name, "src", uuidkey.name * ".jl")
2467+
sourcepath = normpath(env, this_uuidkey.name, "src", this_uuidkey.name * ".jl")
24662468
else
2467-
sourcepath = find_ext_path(normpath(joinpath(env, uuidkey.name)), ext)
2468-
uuidkey = PkgId(uuid5(uuidkey.uuid, ext), ext)
2469+
sourcepath = find_ext_path(normpath(joinpath(env, package_uuidkey.name)), ext)
24692470
end
2470-
#mbypath = manifest_uuid_path(env, uuidkey)
2471-
#if mbypath isa String
2472-
# sourcepath = entry_path(mbypath, uuidkey.name)
2471+
#mbypath = manifest_uuid_path(env, this_uuidkey)
2472+
#if mbypath isa String && isfile_casesensitive(mbypath)
2473+
# sourcepath = mbypath
24732474
#else
24742475
# # if the user deleted the stdlib folder, we next try using their environment
2475-
# sourcepath = locate_package_env(uuidkey)
2476+
# sourcepath = locate_package_env(this_uuidkey)
24762477
# if sourcepath !== nothing
24772478
# sourcepath, env = sourcepath
24782479
# end
24792480
#end
24802481
#if sourcepath === nothing
24812482
# throw(ArgumentError("""
2482-
# Package $(repr("text/plain", uuidkey)) is required but does not seem to be installed.
2483+
# Package $(repr("text/plain", this_uuidkey)) is required but does not seem to be installed.
24832484
# """))
24842485
#end
2485-
set_pkgorigin_version_path(uuidkey, sourcepath)
2486+
set_pkgorigin_version_path(this_uuidkey, sourcepath)
24862487
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH))
2487-
newm = start_loading(uuidkey)
2488+
newm = start_loading(this_uuidkey)
24882489
newm === nothing || return newm
24892490
try
2490-
newm = _require_search_from_serialized(uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
2491+
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
24912492
finally
2492-
end_loading(uuidkey, newm)
2493+
end_loading(this_uuidkey, newm)
24932494
end
24942495
if newm isa Module
24952496
# After successfully loading, notify downstream consumers
2496-
insert_extension_triggers(env, uuidkey)
2497-
run_package_callbacks(uuidkey)
2497+
insert_extension_triggers(env, this_uuidkey)
2498+
run_package_callbacks(this_uuidkey)
24982499
else
24992500
# if the user deleted their bundled depot, next try to load it completely normally
2500-
newm = _require_prelocked(uuidkey)
2501+
newm = _require_prelocked(this_uuidkey)
25012502
end
25022503
return newm
25032504
end

0 commit comments

Comments
 (0)