If I want to use a third-party package with minimal latency overhead, I can do so by having it precompiled. However, I am in the top-level project in a codebase that implements a complex pipeline and get this error when instantiateing:
Is there any way I can debug this error? Bear in mind this project is user-facing, so I am not sure if it can be precompiled, or if only some parts can be precompiled.
AFAIK you should get an actual error message if you call
] precompile
explicitly.
To be safe, I would try it in a fresh REPL.
If the error you get does not occur in your code but in some dependency, try updating your environment. In the worst case you might have to wait for an update of your dependencies I think.
Generally speaking, precompilation should work. Even less overhead is achieved by using PackageCompiler.jl, but you should only attempt this if your package precompiled successfully and you don’t have to make any more changes to it.
julia --project src/MyPackage.jl some-arg-goes-here
And that file looks like this:
using Compat
# Verify if installed Julia version is in range of required Julia versions
minver = VersionNumber("1.6.0")
if VERSION < minver
@error "Your Julia version is $(VERSION) while MyPackage requires Julia version to be a minimum $(minver)"
exit(1)
end
include("AllModules.jl") # I am not defending this design choice
import .AllModules
AllModules.Pipeline.run(Base.ARGS)
The issue is that when I try to use precompile I get this error trace, and I definitely don’t understand this. Happens with or without using Compat above:
What is the reason why you select src/MyPackage.jl as the directory of your environment? Personally, I tend to activate environments in the REPL, but as I understand it, you should put the directory of the Project.toml file here (usually in the parent directory of src/. This is probably not your issue though.
The issue points to the PackageCompiler package, I assume you are not using this, correct?
Which of these things are you trying to do?
Create a package, which is then precompiled upon its first use?
Or use PackageCompiler.jl to compile a script. The script will be run and the fully compiled functions are saved to a file which can be used to start later sessions.
If the answer is 1.:
Possibly the reason why you cannot precompile is that your package is not defined as a module? Usually, a Julia package looks like this:
module MyPackage
using Compat
# Verify if installed Julia version is in range of required Julia versions
minver = VersionNumber("1.6.0")
if VERSION < minver
@error "Your Julia version is $(VERSION) while MyPackage requires Julia version to be a minimum $(minver)"
exit(1)
end
include("AllModules.jl") # I am not defending this design choice
import .AllModules
AllModules.Pipeline.run(Base.ARGS)
end #Module
Does the error go away if you define your package this way and include it with
]activate MyPackage
using MyPackage
If the answer is 2. Try first to run your script with
julia src/MyPackage.jl
if this runs without errors, you can try to follow the steps given in