Invalid call to `sandbox` in Julia 1.11-beta
I encountered the following error when trying to use TestItemRunner in combination with Julia 1.11-beta:
┌ Error: Some Julia code in the VS Code extension crashed
└ @ Main ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/error_handler.jl:15
ERROR: MethodError: no method matching sandbox(::VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#13#15"{Base.PipeEndpoint}}, ::Pkg.Types.Context, ::Pkg.Types.PackageSpec, ::String, ::String, ::Nothing; allow_reresolve::Bool)
The function `sandbox` exists, but no method is defined for this combination of argument types.
Closest candidates are:
sandbox(::Function, ::Pkg.Types.Context, ::Pkg.Types.PackageSpec, ::String, ::Any; preferences, force_latest_compatible_version, allow_earlier_backwards_compatible_versions, allow_reresolve)
@ Pkg ~/.julia/juliaup/julia-1.11.0-beta1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:1814
Stacktrace:
[1] activate(f::VSCodeTestServer.var"#13#15"{Base.PipeEndpoint}, pkg::String; allow_reresolve::Bool)
@ VSCodeTestServer.TestEnv ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/TestEnv/src/julia-1.9/activate_do.jl:17
[2] activate(f::Function, pkg::String)
@ VSCodeTestServer.TestEnv ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/TestEnv/src/julia-1.9/activate_do.jl:12
[3] serve(conn::Base.PipeEndpoint, project_path::String, package_path::String, package_name::String; is_dev::Bool, crashreporting_pipename::Nothing)
@ VSCodeTestServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeTestServer/src/VSCodeTestServer.jl:226
[4] serve(conn::Base.PipeEndpoint, project_path::String, package_path::String, package_name::String)
@ VSCodeTestServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeTestServer/src/VSCodeTestServer.jl:219
[5] top-level scope
@ ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/testserver/testserver_main.jl:17
[6] include(mod::Module, _path::String)
@ Base ./Base.jl:558
[7] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:318
[8] _start()
@ Base ./client.jl:526
it would be useful to have a MWE for this that can be run just in the REPL.
I can reproduce this with the following:
using TestEnv
pkg = "Sunny" # Replace this with something in your environment
TestEnv.activate(pkg) do
()
end
Reduced from the original code: https://github.com/julia-vscode/julia-vscode/blob/9b009459727161f9292d2890d6c5433ec6932960/scripts/packages/VSCodeTestServer/src/VSCodeTestServer.jl#L226-L228
Thanks!
The new sandbox seems to longer require the path argument. I guess this line: https://github.com/JuliaTesting/TestEnv.jl/blob/621a776ea7e67bbd928e933a075cb83123c198ec/src/julia-1.7/activate_do.jl#L17-L20
Could be modified (for Julia 1.11) to become:
return sandbox(ctx, pkgspec, joinpath(path, "test"), test_project_override) do
flush(stdout)
f()
end
As a reference, see how sandbox is being called inside Pkg.jl:
https://github.com/JuliaLang/Pkg.jl/blob/00aa38cb3a85e200c4bd19efef3a15e32e192a8f/src/Operations.jl#L2154-L2155