From 0c0dd9f3060238812b50eb2865ba2501a92a9f35 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Mon, 10 Nov 2025 22:32:35 +0100 Subject: [PATCH 1/2] allow finding stdlibs that are normal packages in the manifest but are now stdlibs (#60061) This helps handling manifest from earlier julia versions. This is kind of the `locate` version of the `identify` fallback in https://github.com/JuliaLang/julia/pull/56148. Need to write a test when this happens (and verify that this fix works). Noted in a slack #gripes comment. --------- Co-authored-by: KristofferC Co-authored-by: Max Horn --- base/loading.jl | 3 ++ test/loading.jl | 11 +++- .../project/deps/BadStdlibDeps2/Manifest.toml | 54 +++++++++++++++++++ test/project/deps/BadStdlibDeps2/Project.toml | 2 + 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/project/deps/BadStdlibDeps2/Manifest.toml create mode 100644 test/project/deps/BadStdlibDeps2/Project.toml diff --git a/base/loading.jl b/base/loading.jl index 39f892c38446c..eee0b820dcb0e 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -463,6 +463,8 @@ function locate_package_env(pkg::PkgId, stopenv::Union{String, Nothing}=nothing) path = manifest_uuid_path(env, pkg) # missing is used as a sentinel to stop looking further down in envs if path === missing + # Before stopping, try stdlib fallback + is_stdlib(pkg) && @goto stdlib_fallback path = nothing @goto done end @@ -474,6 +476,7 @@ function locate_package_env(pkg::PkgId, stopenv::Union{String, Nothing}=nothing) stopenv == env && break end end + @label stdlib_fallback # Allow loading of stdlibs if the name/uuid are given # e.g. if they have been explicitly added to the project/manifest mbypath = manifest_uuid_path(Sys.STDLIB, pkg) diff --git a/test/loading.jl b/test/loading.jl index 5bcd18ff26843..11b67b20609cc 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -1537,12 +1537,21 @@ end mktempdir() do depot # This manifest has a LibGit2 entry that is missing LibGit2_jll, which should be # handled by falling back to the stdlib Project.toml for dependency truth. - badmanifest_test_dir = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps.jl") + badmanifest_test_dir = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps") @test success(addenv( `$(Base.julia_cmd()) --project=$badmanifest_test_dir --startup-file=no -e 'using LibGit2'`, "JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(), )) end + mktempdir() do depot + # This manifest has a LibGit2 entry that has a LibGit2_jll with a git-tree-hash1 + # which simulates an old manifest where LibGit2_jll was not a stdlib + badmanifest_test_dir2 = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps2") + @test success(addenv( + `$(Base.julia_cmd()) --project=$badmanifest_test_dir2 --startup-file=no -e 'using LibGit2'`, + "JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(), + )) + end end @testset "code coverage disabled during precompilation" begin diff --git a/test/project/deps/BadStdlibDeps2/Manifest.toml b/test/project/deps/BadStdlibDeps2/Manifest.toml new file mode 100644 index 0000000000000..988efc8da56f3 --- /dev/null +++ b/test/project/deps/BadStdlibDeps2/Manifest.toml @@ -0,0 +1,54 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.12.0-DEV" +manifest_format = "2.0" +project_hash = "dc9d33b0ee13d9466bdb75b8d375808a534a79ec" + +[[deps.Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" + +[[deps.LibGit2]] +deps = ["NetworkOptions", "Printf", "SHA", "LibGit2_jll"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" + +# This is an stdlib but intentionally has a git-tree-sha1 because +# we are emulating that the manifest comes from a version where +# LibGit2_jll was not an stdlib +[[deps.LibGit2_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] +git-tree-sha1 = "1111111111111111111111111111111111111111" +uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" +version = "1.8.0+0" + +[[deps.LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.11.0+1" + +[[deps.Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" + +[[deps.MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.6+1" + +[[deps.NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" + +[[deps.Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" + +[[deps.SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" + +[[deps.Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" diff --git a/test/project/deps/BadStdlibDeps2/Project.toml b/test/project/deps/BadStdlibDeps2/Project.toml new file mode 100644 index 0000000000000..223889185ea15 --- /dev/null +++ b/test/project/deps/BadStdlibDeps2/Project.toml @@ -0,0 +1,2 @@ +[deps] +LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" From 71fe7fa4cfc5ed61a4b9242ba5654b8c333c19eb Mon Sep 17 00:00:00 2001 From: KristofferC Date: Mon, 17 Nov 2025 15:44:08 +0100 Subject: [PATCH 2/2] fixup depot path --- test/loading.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/loading.jl b/test/loading.jl index 11b67b20609cc..869156dc5382b 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -1534,13 +1534,14 @@ end end @testset "Fallback for stdlib deps if manifest deps aren't found" begin + s = Sys.iswindows() ? ';' : ':' mktempdir() do depot # This manifest has a LibGit2 entry that is missing LibGit2_jll, which should be # handled by falling back to the stdlib Project.toml for dependency truth. badmanifest_test_dir = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps") @test success(addenv( `$(Base.julia_cmd()) --project=$badmanifest_test_dir --startup-file=no -e 'using LibGit2'`, - "JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(), + "JULIA_DEPOT_PATH" => string(depot * Base.Filesystem.pathsep(), s), )) end mktempdir() do depot @@ -1549,7 +1550,7 @@ end badmanifest_test_dir2 = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps2") @test success(addenv( `$(Base.julia_cmd()) --project=$badmanifest_test_dir2 --startup-file=no -e 'using LibGit2'`, - "JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(), + "JULIA_DEPOT_PATH" => string(depot * Base.Filesystem.pathsep(), s), )) end end