Skip to content

Commit

Permalink
Accommodate changes in REPL and Pkg loading in Julia 1.11 (#8)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
LilithHafner authored Oct 12, 2024
1 parent 8092ed0 commit 6778fdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BasicAutoloads"
uuid = "09cdc199-4954-42dd-9e0c-2e47e8233053"
authors = ["Lilith Orion Hafner <[email protected]> and contributors"]
version = "1.0.0"
version = "1.0.1"

[compat]
julia = "1"
Expand Down
4 changes: 3 additions & 1 deletion src/BasicAutoloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ function (al::_Autoload)(@nospecialize(expr))
expr
end
function try_autoinstall(expr::Expr)
REPL = Base.loaded_modules[Base.PkgId(Base.UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL")]
isdefined(Base, :active_repl_backend) || return
REPL = typeof(Base.active_repl_backend).name.module
isdefined(REPL, :install_packages_hooks) || return
expr.head in (:using, :import) || return
for arg in expr.args
arg isa Expr && arg.head == :. && length(arg.args) == 1 || continue
mod = only(arg.args)
mod isa Symbol && Base.identify_package(String(mod)) === nothing || continue
isempty(REPL.install_packages_hooks) && isdefined(REPL, :load_pkg) && REPL.load_pkg()
for f in REPL.install_packages_hooks
Base.invokelatest(f, [mod]) && break
end
Expand Down

4 comments on commit 6778fdd

@LilithHafner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

Release Notes

Fix problem in Julia 1.11 where autoloads only work if REPL has been explicitly loaded (#7, #8)

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117163

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.1 -m "<description of version>" 6778fdd76c20ad5d4f7a6dbb5fc604a5e999d021
git push origin v1.0.1

@LilithHafner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

Release notes:

Fix problem in Julia 1.11 where autoloads only work if REPL has been explicitly loaded (#7, #8)

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/117163

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.1 -m "<description of version>" 6778fdd76c20ad5d4f7a6dbb5fc604a5e999d021
git push origin v1.0.1

Please sign in to comment.