Fatal error after include-workspace-include

Would the following work instead? Basically a gutted-out workspace that does not save the last module.

function cleanworkspace()
    lastbase = Core.Main.Base
    ccall(:jl_new_main_module, Any, ())
    newmain = Core.Main
    ccall(:jl_add_standard_imports, Void, (Any,), newmain)
    eval(newmain, Expr(:toplevel, :(const Base = $(Expr(:quote, lastbase)))))
    empty!(Base.package_locks)
    nothing
end

EDIT the original was overenthusiastic and axed Base.

2 Likes