Precompilation fails on a simple package

Hi there,
just trying to get my first package going, so apologies if this is a newbie question :slight_smile:

I have created a package (“] generate”) called MWE with the following content and have added DiffEqBase and ForwardDiff as packages in the local Project.toml (content of that file below).

MWE.jl content (located in MWE/src)

module MWE

using DiffEqBase
using ForwardDiff

struct Data{chunksize}

end # module

Content of Project.toml (located in folder MWE):

name = "MWE"
uuid = "c31797ed-9657-413b-8bac-66075bf8aeb3"
authors = ["username"]
version = "0.1.0"

DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"

When I am trying to use this simple package (with the local environment activated), I get an error telling me that DiffCache is not defined, as below:

julia> using MWE
[ Info: Precompiling MWE [c31797ed-9657-413b-8bac-66075bf8aeb3]
ERROR: LoadError: UndefVarError: DiffCache not defined
 [1] getproperty(x::Module, f::Symbol)
   @ Base .\Base.jl:26
 [2] top-level scope
   @ ~\[folders cut]\MWE\src\MWE.jl:6
 [3] include
   @ .\Base.jl:386 [inlined]
 [4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
   @ Base .\loading.jl:1213
 [5] top-level scope
   @ none:1
 [6] eval
   @ .\boot.jl:360 [inlined]
 [7] eval(x::Expr)
   @ Base.MainInclude .\client.jl:446
 [8] top-level scope
   @ none:1
in expression starting at [... etc].

I tried using DiffEqBase: DiffCache at the top of MWE.jl as well (and of course altering the a:: line accordingly), but it also doesn’t work.

Can anyone help? Seems like a really basic problem that is probably caused by me doing something wrong in terms of package management…but what?

When I am c&p-ing the module code into the REPL, it’s working fine.

Welcome, and thank you for the detailed MWE! I can confirm that I see the same behavior. What julia verison are you on (versioninfo())? Which versions of DiffEqBase and ForwardDiff are installed (]st)?

This probably has to do with the use of Requires.jl in DiffEqBase, since that struct is requiring ForwardDiff. I had hoped simply swapping the using statements would have worked, but seems like this isn’t the case. Probably best to open an issue at DiffEqBase.

Thanks for the quick reply. Already good that somebody else is able to reproduce it! :slight_smile:
Here is the data:


Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)


Project MWE v0.1.0
      Status `[...systempath...]\MWE\Project.toml`
  [2b5f629d] DiffEqBase v6.70.0
  [f6369f11] ForwardDiff v0.10.18

I’ll file an issue with DiffEqBase (as soon as I have reminded myself on how to do it!)

1 Like

For completeness, link to the DiffEqBase issue:

This is fixed by using GitHub - SciML/PreallocationTools.jl: Speed at all costs (which will be registered in 3 days)

1 Like

Thanks for this. Works out well.