Skip to content

Commit 861187f

Browse files
IanButterworthKristofferC
authored andcommitted
Fix is_stdlib uses when julia_version is used (#4534)
(cherry picked from commit 1e90f07)
1 parent a988d36 commit 861187f

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/Operations.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ function resolve_versions!(
724724

725725
jll_fix = Dict{UUID, VersionNumber}()
726726
for pkg in pkgs
727-
if !is_stdlib(pkg.uuid) && endswith(pkg.name, "_jll") && pkg.version isa VersionNumber
727+
if !is_stdlib(pkg.uuid, julia_version) && endswith(pkg.name, "_jll") && pkg.version isa VersionNumber
728728
jll_fix[pkg.uuid] = pkg.version
729729
end
730730
end
@@ -775,7 +775,7 @@ function resolve_versions!(
775775
# Unless using the unbounded or historical resolver, always allow stdlibs to update. Helps if the previous resolve
776776
# happened on a different julia version / commit and the stdlib version in the manifest is not the current stdlib version
777777
unbind_stdlibs = julia_version === VERSION
778-
reqs = Resolve.Requires(pkg.uuid => is_stdlib(pkg.uuid) && unbind_stdlibs ? VersionSpec("*") : VersionSpec(pkg.version) for pkg in pkgs)
778+
reqs = Resolve.Requires(pkg.uuid => is_stdlib(pkg.uuid, julia_version) && unbind_stdlibs ? VersionSpec("*") : VersionSpec(pkg.version) for pkg in pkgs)
779779
deps_map_compressed, compat_map_compressed, weak_deps_map_compressed, weak_compat_map_compressed, pkg_versions_map, pkg_versions_per_registry, uuid_to_name, reqs, fixed = deps_graph(env, registries, names, reqs, fixed, julia_version, installed_only)
780780
graph = Resolve.Graph(deps_map_compressed, compat_map_compressed, weak_deps_map_compressed, weak_compat_map_compressed, pkg_versions_map, pkg_versions_per_registry, uuid_to_name, reqs, fixed, false, julia_version)
781781
Resolve.simplify_graph!(graph)
@@ -906,6 +906,7 @@ function deps_graph(
906906
# unregistered stdlib we must special-case it here. This is further
907907
# complicated by the fact that we can ask this question relative to
908908
# a Julia version.
909+
# CRITICAL: Never resolve stdlibs from registry for target julia_version
909910
if (julia_version != VERSION && is_unregistered_stdlib(uuid)) || uuid_is_stdlib
910911
# We use our historical stdlib versioning data to unpack the version, deps and weakdeps of this uuid
911912
stdlib_info = stdlibs_for_julia_version[uuid]
@@ -1969,7 +1970,7 @@ function update_package_add(ctx::Context, pkg::PackageSpec, entry::PackageEntry,
19691970
if entry.path !== nothing || entry.repo.source !== nothing || pkg.repo.source !== nothing
19701971
return pkg # overwrite everything, nothing to copy over
19711972
end
1972-
if is_stdlib(pkg.uuid)
1973+
if is_stdlib(pkg.uuid, ctx.julia_version)
19731974
return pkg # stdlibs are not versioned like other packages
19741975
elseif is_dep && (
19751976
(isa(pkg.version, VersionNumber) && entry.version == pkg.version) ||
@@ -2468,18 +2469,19 @@ function up(
24682469
return build_versions(ctx, union(new_apply, new_git))
24692470
end
24702471

2471-
function update_package_pin!(registries::Vector{Registry.RegistryInstance}, pkg::PackageSpec, entry::Union{Nothing, PackageEntry})
2472+
function update_package_pin!(ctx::Context, pkg::PackageSpec, entry::Union{Nothing, PackageEntry})
24722473
if entry === nothing
24732474
cmd = Pkg.in_repl_mode() ? "pkg> resolve" : "Pkg.resolve()"
24742475
pkgerror("package $(err_rep(pkg)) not found in the manifest, run `$cmd` and retry.")
24752476
end
2477+
registries = ctx.registries
24762478

24772479
#if entry.pinned && pkg.version == VersionSpec()
24782480
# println(ctx.io, "package $(err_rep(pkg)) already pinned")
24792481
#end
24802482
# update pinned package
24812483
pkg.pinned = true
2482-
if is_stdlib(pkg.uuid)
2484+
if is_stdlib(pkg.uuid, ctx.julia_version)
24832485
return nothing # nothing left to do
24842486
elseif pkg.version == VersionSpec()
24852487
pkg.version = entry.version # pin at current version
@@ -2500,7 +2502,7 @@ end
25002502
is_fully_pinned(ctx::Context) = !isempty(ctx.env.manifest.deps) && all(kv -> last(kv).pinned, ctx.env.manifest.deps)
25012503

25022504
function pin(ctx::Context, pkgs::Vector{PackageSpec})
2503-
foreach(pkg -> update_package_pin!(ctx.registries, pkg, manifest_info(ctx.env.manifest, pkg.uuid)), pkgs)
2505+
foreach(pkg -> update_package_pin!(ctx, pkg, manifest_info(ctx.env.manifest, pkg.uuid)), pkgs)
25042506
pkgs = load_direct_deps(ctx.env, pkgs)
25052507

25062508
# TODO: change pin to not take a version and just have it pin on the current version. Then there is no need to resolve after a pin

test/historical_stdlib_version.jl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,8 @@ isolate(loaded_depot = true) do
310310

311311
Pkg.activate(temp = true)
312312
# Stdlib add (julia_version == nothing)
313-
# Note: this is currently known to be broken, we get the wrong GMP_jll!
314313
Pkg.add(; name = "GMP_jll", version = v"6.2.1+1", julia_version = nothing)
315-
@test_broken Pkg.dependencies()[GMP_jll_UUID].version === v"6.2.1+1"
314+
@test Pkg.dependencies()[GMP_jll_UUID].version === v"6.2.1+1"
316315
end
317316

318317
@testset "julia_version = nothing" begin
@@ -349,6 +348,26 @@ isolate(loaded_depot = true) do
349348
end
350349
end
351350
end
351+
352+
@testset "Artifacts stdlib never falls back to registry" begin
353+
# Test that when resolving for Julia 1.10 (where Artifacts is a stdlib with version=nothing),
354+
# Pkg never installs the external Artifacts v1.3.0 from the registry
355+
Pkg.activate(temp = true)
356+
# Add a package that depends on Artifacts with julia_version = v"1.10"
357+
# Artifacts should remain a stdlib, not be resolved to v1.3.0 from registry
358+
ctx = Pkg.Types.Context(; julia_version = v"1.10")
359+
# GMP_jll for Julia 1.10 should bring in Artifacts as a dependency
360+
Pkg.add(ctx, [PackageSpec(; name = "GMP_jll")])
361+
362+
# Check that Artifacts is not in the manifest as an external package
363+
# (If it were incorrectly resolved from registry, it would appear with version v1.3.0)
364+
artifacts_uuid = Base.UUID("56f22d72-fd6d-98f1-02f0-08ddc0907c33")
365+
manifest_entry = get(ctx.env.manifest, artifacts_uuid, nothing)
366+
if manifest_entry !== nothing
367+
# Artifacts should not have v1.3.0 (the registry version)
368+
@test manifest_entry.version != v"1.3.0"
369+
end
370+
end
352371
end
353372
HistoricalStdlibVersions.unregister!()
354373
end

0 commit comments

Comments
 (0)