Skip to content

Commit 0d0619f

Browse files
load Pkg if needed to reinstate missing package add prompt
1 parent 16e61e2 commit 0d0619f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

stdlib/REPL/src/REPL.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend, mod::Module)
158158
put!(backend.response_channel, Pair{Any, Bool}(lasterr, true))
159159
else
160160
backend.in_eval = true
161+
isempty(install_packages_hooks) && load_pkg()
161162
if !isempty(install_packages_hooks)
162163
check_for_missing_packages_and_run_hooks(ast)
163164
end
@@ -1523,6 +1524,15 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef)
15231524
nothing
15241525
end
15251526

1527+
function load_pkg()
1528+
pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
1529+
if Base.locate_package(pkgid) !== nothing # Only try load Pkg if we can find it
1530+
Pkg = Base.require(pkgid)
1531+
return Pkg
1532+
end
1533+
return nothing
1534+
end
1535+
15261536
module Numbered
15271537

15281538
using ..REPL
@@ -1595,7 +1605,6 @@ function __current_ast_transforms(backend)
15951605
end
15961606
end
15971607

1598-
15991608
function numbered_prompt!(repl::LineEditREPL=Base.active_repl, backend=nothing)
16001609
n = Ref{Int}(0)
16011610
set_prompt(repl, n)

0 commit comments

Comments
 (0)