From 0993350cd5f31b037080ba411f54f08ef2ade6ff Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 9 Feb 2021 22:25:37 +0100 Subject: [PATCH] [loading] Search in Sys.STDLIB if name/uuid is known. (#39572) Locating a package with known uuid means the uuid was either found in a manifest in LOAD_PATH or a "package folder" in LOAD_PATH. However, looking up the package entrypoint fails for stdlibs that are not in the sysimage, even if they have been explicitly added to project/manifest by the user. This patch allows looking in Sys.STDLIB after stdlibs, fixes #39504. (cherry picked from commit 5d7e13f0dec118f86df2cf3d8999549cd47c32c2) --- base/loading.jl | 4 ++++ test/cmdlineargs.jl | 1 + 2 files changed, 5 insertions(+) diff --git a/base/loading.jl b/base/loading.jl index 093e14e00e74e..41e5e8a55beb4 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -290,6 +290,10 @@ function locate_package(pkg::PkgId)::Union{Nothing,String} path = manifest_uuid_path(env, pkg) path === nothing || return entry_path(path, pkg.name) end + # Allow loading of stdlibs if the name/uuid are given + # e.g. if they have been explicitly added to the project/manifest + path = manifest_uuid_path(Sys.STDLIB::String, pkg) + path === nothing || return entry_path(path, pkg.name) end return nothing end diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 3a331d406d886..ebf1525d81e52 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -71,6 +71,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no` end let v = readchomperrors(`$exename -i -e ' empty!(LOAD_PATH) + @eval Sys STDLIB=mktempdir() Base.unreference_module(Base.PkgId(Base.UUID(0xb77e0a4c_d291_57a0_90e8_8db25a27a240), "InteractiveUtils")) '`) # simulate not having a working version of InteractiveUtils,