diff --git a/src/Operations.jl b/src/Operations.jl index dc4396167e..3cf9c77fe5 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -763,7 +763,7 @@ function resolve_versions!( jll_fix = Dict{UUID, VersionNumber}() for pkg in pkgs - if !is_stdlib(pkg.uuid) && endswith(pkg.name, "_jll") && pkg.version isa VersionNumber + if !is_stdlib(pkg.uuid, julia_version) && endswith(pkg.name, "_jll") && pkg.version isa VersionNumber jll_fix[pkg.uuid] = pkg.version end end @@ -814,7 +814,7 @@ function resolve_versions!( # Unless using the unbounded or historical resolver, always allow stdlibs to update. Helps if the previous resolve # happened on a different julia version / commit and the stdlib version in the manifest is not the current stdlib version unbind_stdlibs = julia_version === VERSION - reqs = Resolve.Requires(pkg.uuid => is_stdlib(pkg.uuid) && unbind_stdlibs ? VersionSpec("*") : VersionSpec(pkg.version) for pkg in pkgs) + reqs = Resolve.Requires(pkg.uuid => is_stdlib(pkg.uuid, julia_version) && unbind_stdlibs ? VersionSpec("*") : VersionSpec(pkg.version) for pkg in pkgs) 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) 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) Resolve.simplify_graph!(graph) @@ -945,6 +945,7 @@ function deps_graph( # unregistered stdlib we must special-case it here. This is further # complicated by the fact that we can ask this question relative to # a Julia version. + # CRITICAL: Never resolve stdlibs from registry for target julia_version if (julia_version != VERSION && is_unregistered_stdlib(uuid)) || uuid_is_stdlib # We use our historical stdlib versioning data to unpack the version, deps and weakdeps of this uuid stdlib_info = stdlibs_for_julia_version[uuid] @@ -2012,7 +2013,7 @@ function update_package_add(ctx::Context, pkg::PackageSpec, entry::PackageEntry, if entry.path !== nothing || entry.repo.source !== nothing || pkg.repo.source !== nothing return pkg # overwrite everything, nothing to copy over end - if is_stdlib(pkg.uuid) + if is_stdlib(pkg.uuid, ctx.julia_version) return pkg # stdlibs are not versioned like other packages elseif is_dep && ( (isa(pkg.version, VersionNumber) && entry.version == pkg.version) || @@ -2511,18 +2512,19 @@ function up( return build_versions(ctx, union(new_apply, new_git)) end -function update_package_pin!(registries::Vector{Registry.RegistryInstance}, pkg::PackageSpec, entry::Union{Nothing, PackageEntry}) +function update_package_pin!(ctx::Context, pkg::PackageSpec, entry::Union{Nothing, PackageEntry}) if entry === nothing cmd = Pkg.in_repl_mode() ? "pkg> resolve" : "Pkg.resolve()" pkgerror("package $(err_rep(pkg)) not found in the manifest, run `$cmd` and retry.") end + registries = ctx.registries #if entry.pinned && pkg.version == VersionSpec() # println(ctx.io, "package $(err_rep(pkg)) already pinned") #end # update pinned package pkg.pinned = true - if is_stdlib(pkg.uuid) + if is_stdlib(pkg.uuid, ctx.julia_version) return nothing # nothing left to do elseif pkg.version == VersionSpec() pkg.version = entry.version # pin at current version @@ -2543,7 +2545,7 @@ end is_fully_pinned(ctx::Context) = !isempty(ctx.env.manifest.deps) && all(kv -> last(kv).pinned, ctx.env.manifest.deps) function pin(ctx::Context, pkgs::Vector{PackageSpec}) - foreach(pkg -> update_package_pin!(ctx.registries, pkg, manifest_info(ctx.env.manifest, pkg.uuid)), pkgs) + foreach(pkg -> update_package_pin!(ctx, pkg, manifest_info(ctx.env.manifest, pkg.uuid)), pkgs) pkgs = load_direct_deps(ctx.env, pkgs) # 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 diff --git a/test/historical_stdlib_version.jl b/test/historical_stdlib_version.jl index 3f4967737b..c94164e338 100644 --- a/test/historical_stdlib_version.jl +++ b/test/historical_stdlib_version.jl @@ -310,9 +310,8 @@ isolate(loaded_depot = true) do Pkg.activate(temp = true) # Stdlib add (julia_version == nothing) - # Note: this is currently known to be broken, we get the wrong GMP_jll! Pkg.add(; name = "GMP_jll", version = v"6.2.1+1", julia_version = nothing) - @test_broken Pkg.dependencies()[GMP_jll_UUID].version === v"6.2.1+1" + @test Pkg.dependencies()[GMP_jll_UUID].version === v"6.2.1+1" end @testset "julia_version = nothing" begin @@ -349,6 +348,26 @@ isolate(loaded_depot = true) do end end end + + @testset "Artifacts stdlib never falls back to registry" begin + # Test that when resolving for Julia 1.10 (where Artifacts is a stdlib with version=nothing), + # Pkg never installs the external Artifacts v1.3.0 from the registry + Pkg.activate(temp = true) + # Add a package that depends on Artifacts with julia_version = v"1.10" + # Artifacts should remain a stdlib, not be resolved to v1.3.0 from registry + ctx = Pkg.Types.Context(; julia_version = v"1.10") + # GMP_jll for Julia 1.10 should bring in Artifacts as a dependency + Pkg.add(ctx, [PackageSpec(; name = "GMP_jll")]) + + # Check that Artifacts is not in the manifest as an external package + # (If it were incorrectly resolved from registry, it would appear with version v1.3.0) + artifacts_uuid = Base.UUID("56f22d72-fd6d-98f1-02f0-08ddc0907c33") + manifest_entry = get(ctx.env.manifest, artifacts_uuid, nothing) + if manifest_entry !== nothing + # Artifacts should not have v1.3.0 (the registry version) + @test manifest_entry.version != v"1.3.0" + end + end end HistoricalStdlibVersions.unregister!() end