Skip to content

Commit 1e90f07

Browse files
Fix is_stdlib uses when julia_version is used (#4534)
1 parent 3f0c20e commit 1e90f07

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
@@ -763,7 +763,7 @@ function resolve_versions!(
763763

764764
jll_fix = Dict{UUID, VersionNumber}()
765765
for pkg in pkgs
766-
if !is_stdlib(pkg.uuid) && endswith(pkg.name, "_jll") && pkg.version isa VersionNumber
766+
if !is_stdlib(pkg.uuid, julia_version) && endswith(pkg.name, "_jll") && pkg.version isa VersionNumber
767767
jll_fix[pkg.uuid] = pkg.version
768768
end
769769
end
@@ -814,7 +814,7 @@ function resolve_versions!(
814814
# Unless using the unbounded or historical resolver, always allow stdlibs to update. Helps if the previous resolve
815815
# happened on a different julia version / commit and the stdlib version in the manifest is not the current stdlib version
816816
unbind_stdlibs = julia_version === VERSION
817-
reqs = Resolve.Requires(pkg.uuid => is_stdlib(pkg.uuid) && unbind_stdlibs ? VersionSpec("*") : VersionSpec(pkg.version) for pkg in pkgs)
817+
reqs = Resolve.Requires(pkg.uuid => is_stdlib(pkg.uuid, julia_version) && unbind_stdlibs ? VersionSpec("*") : VersionSpec(pkg.version) for pkg in pkgs)
818818
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)
819819
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)
820820
Resolve.simplify_graph!(graph)
@@ -945,6 +945,7 @@ function deps_graph(
945945
# unregistered stdlib we must special-case it here. This is further
946946
# complicated by the fact that we can ask this question relative to
947947
# a Julia version.
948+
# CRITICAL: Never resolve stdlibs from registry for target julia_version
948949
if (julia_version != VERSION && is_unregistered_stdlib(uuid)) || uuid_is_stdlib
949950
# We use our historical stdlib versioning data to unpack the version, deps and weakdeps of this uuid
950951
stdlib_info = stdlibs_for_julia_version[uuid]
@@ -2012,7 +2013,7 @@ function update_package_add(ctx::Context, pkg::PackageSpec, entry::PackageEntry,
20122013
if entry.path !== nothing || entry.repo.source !== nothing || pkg.repo.source !== nothing
20132014
return pkg # overwrite everything, nothing to copy over
20142015
end
2015-
if is_stdlib(pkg.uuid)
2016+
if is_stdlib(pkg.uuid, ctx.julia_version)
20162017
return pkg # stdlibs are not versioned like other packages
20172018
elseif is_dep && (
20182019
(isa(pkg.version, VersionNumber) && entry.version == pkg.version) ||
@@ -2511,18 +2512,19 @@ function up(
25112512
return build_versions(ctx, union(new_apply, new_git))
25122513
end
25132514

2514-
function update_package_pin!(registries::Vector{Registry.RegistryInstance}, pkg::PackageSpec, entry::Union{Nothing, PackageEntry})
2515+
function update_package_pin!(ctx::Context, pkg::PackageSpec, entry::Union{Nothing, PackageEntry})
25152516
if entry === nothing
25162517
cmd = Pkg.in_repl_mode() ? "pkg> resolve" : "Pkg.resolve()"
25172518
pkgerror("package $(err_rep(pkg)) not found in the manifest, run `$cmd` and retry.")
25182519
end
2520+
registries = ctx.registries
25192521

25202522
#if entry.pinned && pkg.version == VersionSpec()
25212523
# println(ctx.io, "package $(err_rep(pkg)) already pinned")
25222524
#end
25232525
# update pinned package
25242526
pkg.pinned = true
2525-
if is_stdlib(pkg.uuid)
2527+
if is_stdlib(pkg.uuid, ctx.julia_version)
25262528
return nothing # nothing left to do
25272529
elseif pkg.version == VersionSpec()
25282530
pkg.version = entry.version # pin at current version
@@ -2543,7 +2545,7 @@ end
25432545
is_fully_pinned(ctx::Context) = !isempty(ctx.env.manifest.deps) && all(kv -> last(kv).pinned, ctx.env.manifest.deps)
25442546

25452547
function pin(ctx::Context, pkgs::Vector{PackageSpec})
2546-
foreach(pkg -> update_package_pin!(ctx.registries, pkg, manifest_info(ctx.env.manifest, pkg.uuid)), pkgs)
2548+
foreach(pkg -> update_package_pin!(ctx, pkg, manifest_info(ctx.env.manifest, pkg.uuid)), pkgs)
25472549
pkgs = load_direct_deps(ctx.env, pkgs)
25482550

25492551
# 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)