Open
Description
As far as I understand, these should be equivalent.
dependencies = [PackageSpec(; name="CMake_jll", version = "3.24.3")]
platform = Base.BinaryPlatforms.Platform("x86_64", "linux"; libc="musl")
@testset "good" begin
Pkg.activate(temp=true)
Pkg.add(deepcopy(dependencies); platform, julia_version=nothing)
end
@testset "bad" begin
Pkg.activate(temp=true)
ctx = Pkg.Types.Context(;julia_version=nothing)
Pkg.add(ctx, deepcopy(dependencies); platform)
end
But the latter errors with
Activating new project at `/var/folders/1z/jf841bdj73bdj3vk7kc7f_3w0000gn/T/jl_C6cT0a`
Resolving package versions...
bad: Error During Test at REPL[20]:1
Got exception outside of a @test
MethodError: no method matching length(::Pkg.Versions.VersionSpec)
The function `length` exists, but no method is defined for this combination of argument types.
Closest candidates are:
length(::Base.MethodSpecializations)
@ Base runtime_internals.jl:1643
length(::Core.SimpleVector)
@ Base essentials.jl:934
length(::Markdown.MD)
@ Markdown ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/Markdown/src/parse/parse.jl:35
...
Stacktrace:
[1] union!(s::Set{Any}, itr::Pkg.Versions.VersionSpec)
@ Base ./abstractset.jl:104
[2] intersect!(s::Set{Any}, itr::Pkg.Versions.VersionSpec)
@ Base ./abstractset.jl:197
[3] _shrink(shrinker!::typeof(intersect!), itr::String, itrs::Tuple{Pkg.Versions.VersionSpec})
@ Base ./array.jl:3113
[4] intersect(itr::String, itrs::Pkg.Versions.VersionSpec)
@ Base ./array.jl:3117
[5] resolve_versions!(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, julia_version::Nothing, installed_only::Bool)
@ Pkg.Operations ~/Documents/GitHub/Pkg.jl/src/Operations.jl:502
[6] targeted_resolve(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel, julia_version::Nothing)
@ Pkg.Operations ~/Documents/GitHub/Pkg.jl/src/Operations.jl:1636
[7] tiered_resolve(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, julia_version::Nothing, try_all_installed::Bool)
@ Pkg.Operations ~/Documents/GitHub/Pkg.jl/src/Operations.jl:1601
[8] _resolve(io::IOContext{IO}, env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel, julia_version::Nothing)
@ Pkg.Operations ~/Documents/GitHub/Pkg.jl/src/Operations.jl:1644
[9] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, new_git::Set{Base.UUID}; allow_autoprecomp::Bool, preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, target::Symbol)
@ Pkg.Operations ~/Documents/GitHub/Pkg.jl/src/Operations.jl:1679
[10] add
@ ~/Documents/GitHub/Pkg.jl/src/Operations.jl:1655 [inlined]
[11] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, target::Symbol, allow_autoprecomp::Bool, kwargs::@Kwargs{})
@ Pkg.API ~/Documents/GitHub/Pkg.jl/src/API.jl:317
[12] top-level scope
@ REPL[20]:2
[13] macro expansion
@ ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/Test/src/Test.jl:1771 [inlined]
[14] macro expansion
@ REPL[20]:4 [inlined]
[15] __repl_entry_eval_expanded_with_loc(mod::Module, ast::Any, toplevel_file::Ref{Ptr{UInt8}}, toplevel_line::Ref{Int32})
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:340
[16] #invokelatest#1
@ ./essentials.jl:1057 [inlined]
[17] invokelatest
@ ./essentials.jl:1053 [inlined]
[18] toplevel_eval_with_hooks(mod::Module, ast::Any, toplevel_file::Any, toplevel_line::Any)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:347
[19] toplevel_eval_with_hooks(mod::Module, ast::Any, toplevel_file::Any, toplevel_line::Any) (repeats 2 times)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:351
[20] toplevel_eval_with_hooks
@ ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:344 [inlined]
[21] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:369
[22] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:481
[23] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:466
[24] start_repl_backend
@ ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:463 [inlined]
[25] run_repl(repl::AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:689
[26] run_repl(repl::AbstractREPL, consumer::Any)
@ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:675
[27] run_std_repl(REPL::Module, quiet::Bool, banner::Symbol, history_file::Bool)
@ Base ./client.jl:488
[28] #invokelatest#1
@ ./essentials.jl:1057 [inlined]
[29] invokelatest
@ ./essentials.jl:1053 [inlined]
[30] run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool)
@ Base ./client.jl:509
[31] repl_main
@ ./client.jl:592 [inlined]
[32] _start()
@ Base ./client.jl:567
Test Summary: | Error Total Time
bad | 1 1 0.0s
RNG of the outermost testset: Random.Xoshiro(0xb30ae9081d072a8d, 0x15962e795ab11340, 0x1d83a638e6bdaf46, 0xa70a192cd5f0ac41, 0x18a663ca88638672)
ERROR: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.