From 732231e49b766d04ee153f4f6f6bf803b8f57309 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 16 Dec 2024 13:39:15 +0100 Subject: [PATCH] Fix environment activation. --- scripts/evaluate.jl | 28 +++++++++++++++++----------- scripts/precompile.jl | 4 ++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/scripts/evaluate.jl b/scripts/evaluate.jl index 94afd796..bb772cc5 100644 --- a/scripts/evaluate.jl +++ b/scripts/evaluate.jl @@ -10,14 +10,6 @@ print("\n\n", '#'^80, "\n# Set-up\n#\n\n") t0 = cpu_time() -# we install PkgEval dependencies in a separate environment -try - Pkg.DEFAULT_IO[] = devnull - Pkg.activate("pkgeval"; shared=true) -finally - Pkg.DEFAULT_IO[] = nothing -end - deps = String[] if config.goal === :test @@ -36,11 +28,20 @@ if config.rr == RREnabled # the dependencies of the package under evaluation. However, in the session # where we load BugReporting.jl we'll never actually load the package we # want to test, only re-start Julia under rr, so this should be fine. - println(io, "pushfirst!(LOAD_PATH, $(repr(Base.ACTIVE_PROJECT[])))") + println(io, """ + project = Base.active_project() + + prepend!(LOAD_PATH, $(repr(LOAD_PATH))) + using Pkg + + Pkg.activate("pkgeval"; shared=true) + using BugReporting + + Pkg.activate(project) + """) # this code is essentially what --bug-report from InteractiveUtils does println(io, """ - using BugReporting ENV["ENABLE_GDBLISTENER"] = "1" println("Switching execution to under rr") BugReporting.make_interactive_report("rr-local", ARGS) @@ -54,6 +55,10 @@ if !isempty(deps) Pkg.DEFAULT_IO[] = io try println("Installing PkgEval dependencies (", join(deps, ", "), ")...") + + # we install PkgEval dependencies in a separate environment + Pkg.activate("pkgeval"; shared=true) + Pkg.add(deps) catch # something went wrong installing PkgEval's dependencies @@ -183,7 +188,8 @@ t0 = cpu_time() io0 = io_bytes() try # we load the package in a session mimicking Pkg's sandbox, - # because that's what we previously precompiled the package in. + # because that's what we previously precompiled the package for. + println("Loading $(pkg.name)...") run(```$(Base.julia_cmd()) --check-bounds=yes --inline=$(Bool(Base.JLOptions().can_inline) ? "yes" : "no") diff --git a/scripts/precompile.jl b/scripts/precompile.jl index 9a18f9ef..39a1bf66 100644 --- a/scripts/precompile.jl +++ b/scripts/precompile.jl @@ -27,6 +27,10 @@ if config.goal === :test Pkg.activate() Pkg.DEFAULT_IO[] = nothing end +else + Pkg.DEFAULT_IO[] = devnull + Pkg.activate() + Pkg.DEFAULT_IO[] = nothing end println("Precompiling package dependencies...")