Skip to content

Using DiffCache in struct of a local package breaks precompilation of the local package #687

@thomvet

Description

@thomvet

Reference to the Julia discourse post:
https://discourse.julialang.org/t/precompilation-fails-on-a-simple-package/65423/2

Summary:
Using DiffEqBase's DiffCache in the definition of a struct field causes precompilation to fail, because DiffCache cannot be found. Is this an issue that can be fixed from the side of DiffEqBase?

Description and MWE:
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}
    a::DiffEqBase.DiffCache{Array{Float64,1},Array{ForwardDiff.Dual{nothing,Float64,chunksize},1}}
    b::Float64
end

end # module

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

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

[deps]
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
Stacktrace:
 [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. Reversing order of using ForwardDiff and using DiffEqBase doesn't help either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions