Skip to content

Commit 6778fdd

Browse files
authored
Accommodate changes in REPL and Pkg loading in Julia 1.11 (#8)
- Get REPL by inspecting the type of Base.active_repl instead of inspecting the list of loaded packages becuase in 1.11, REPL can be loaded and still not in Base.loaded_modules - Follow REPL by loading pkg if it has not been already so that the package install prompt works even if a user hasn't entered pkg mode - Bump version
1 parent 8092ed0 commit 6778fdd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BasicAutoloads"
22
uuid = "09cdc199-4954-42dd-9e0c-2e47e8233053"
33
authors = ["Lilith Orion Hafner <[email protected]> and contributors"]
4-
version = "1.0.0"
4+
version = "1.0.1"
55

66
[compat]
77
julia = "1"

src/BasicAutoloads.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ function (al::_Autoload)(@nospecialize(expr))
6464
expr
6565
end
6666
function try_autoinstall(expr::Expr)
67-
REPL = Base.loaded_modules[Base.PkgId(Base.UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL")]
67+
isdefined(Base, :active_repl_backend) || return
68+
REPL = typeof(Base.active_repl_backend).name.module
6869
isdefined(REPL, :install_packages_hooks) || return
6970
expr.head in (:using, :import) || return
7071
for arg in expr.args
7172
arg isa Expr && arg.head == :. && length(arg.args) == 1 || continue
7273
mod = only(arg.args)
7374
mod isa Symbol && Base.identify_package(String(mod)) === nothing || continue
75+
isempty(REPL.install_packages_hooks) && isdefined(REPL, :load_pkg) && REPL.load_pkg()
7476
for f in REPL.install_packages_hooks
7577
Base.invokelatest(f, [mod]) && break
7678
end

0 commit comments

Comments
 (0)