-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Custom loader undefined when precompilation of a module fails. #23654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Well, I believe the error of the undefined custom loader to always occur when precompilation of a module happens. Regardless of whether successful or not. But I haven't properly confirmed, yet. |
And this would be my use-case: """
The module `PkgAutoInstall` will automatically download and add
all registered packages with a name that corresponds to a module `m`
that is intended to be loaded, viz. with `using m`, `import m`, or
`require(:m)` statements, respectively. This will also automatically
add packages that other package authors forgot to add to their `REQUIRE`
file.
Usage:
1) Type `Pkg.add("PkgAutoInstall")` -- for the last time; then,
2) Type `using PkgAutoInstall`, or add the same to your `~/.juliarc.jl`
3) Test it with a package that you haven't installed yet.
Note: If you have other custom directories in your `Base.LOAD_PATH`,
make sure to first add those, then load PkgAutoInstall afterwards.
"""
module PkgAutoInstall
struct PkgAutoInstaller end
import Base: load_hook
function Base.load_hook(prefix::PkgAutoInstaller, name::String, found)
# drop out if there is already a match
found !== nothing && return found
# otherwise, figure out whether there is a package of that name
try
Pkg.available(name) # if this doesn't throw, then install it
catch err
warn("PkgAutoInstall: '$name' is not a registered package. " *
"Cannot install automatically. Typo?")
return nothing
end
info("PkgAutoInstall: Installing registered package '$name'...")
try
Pkg.add(name)
catch err
warn("PkgAutoInstall: Installation of registered package '$name' " *
"failed. $err")
return nothing
end
info("PkgAutoInstall: Registered package '$name' is now available.")
# Now try again, using the default Pkg loader
Base.load_hook(string(Pkg.dir()), name, nothing)
end
__init__() = begin
push!(Base.LOAD_PATH, PkgAutoInstaller())
info("PkgAutoInstall: Automatic installation of registered packages " *
"is now enabled.")
end
end # module |
I don't know what |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
While observing the current error with StaticArrays on current Julia master, I also observed an issue when using a custom module loader for modules to be precompiled but fail.
An MWE looks like the following: Create a module that should precompile, but fails (this simulates the StaticArrays problem):
Then, creating a custom module loader in a new module, and trying to import the above failing module, also fails as shown below.
Without
__precompile__()
inThisOneFails.jl
everything looks fine as it should:The text was updated successfully, but these errors were encountered: