JuliaDiff / AbstractDifferentiation.jl

An abstract interface for automatic differentiation.
https://juliadiff.org/AbstractDifferentiation.jl/
MIT License
137 stars 18 forks source link

LoadError: UndefVarError: StaticArrays not defined #73

Closed prbzrg closed 1 year ago

prbzrg commented 1 year ago

When both AbstractDifferentiation and ForwardDiff get imported. There is a warning!

┌ Warning: Error requiring `ForwardDiff` from `AbstractDifferentiation`
│   exception =
│    LoadError: UndefVarError: StaticArrays not defined
│    Stacktrace:
│      [1] include(mod::Module, _path::String)
│        @ Base .\Base.jl:419
│      [2] include(x::String)
│        @ AbstractDifferentiation C:\Users\Hossein Pourbozorg\.julia\packages\AbstractDifferentiation\o62DE\src\AbstractDifferentiation.jl:1
│      [3] top-level scope
│        @ C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\Requires.jl:40
│      [4] eval
│        @ .\boot.jl:368 [inlined]
│      [5] eval
│        @ C:\Users\Hossein Pourbozorg\.julia\packages\AbstractDifferentiation\o62DE\src\AbstractDifferentiation.jl:1 [inlined]
│      [6] (::AbstractDifferentiation.var"#55#70")()
│        @ AbstractDifferentiation C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:101
│      [7] macro expansion
│        @ timing.jl:382 [inlined]
│      [8] err(f::Any, listener::Module, modname::String, file::String, line::Any)
│        @ Requires C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:47
│      [9] (::AbstractDifferentiation.var"#54#69")()
│        @ AbstractDifferentiation C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:100
│     [10] withpath(f::Any, path::String)
│        @ Requires C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:37
│     [11] (::AbstractDifferentiation.var"#53#68")()
│        @ AbstractDifferentiation C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:99
│     [12] #invokelatest#2
│        @ .\essentials.jl:729 [inlined]
│     [13] invokelatest
│        @ .\essentials.jl:726 [inlined]
│     [14] foreach(f::typeof(Base.invokelatest), itr::Vector{Function})
│        @ Base .\abstractarray.jl:2774
│     [15] loadpkg(pkg::Base.PkgId)
│        @ Requires C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:27
│     [16] #invokelatest#2
│        @ .\essentials.jl:729 [inlined]
│     [17] invokelatest
│        @ .\essentials.jl:726 [inlined]
│     [18] run_package_callbacks(modkey::Base.PkgId)
│        @ Base .\loading.jl:869
│     [19] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, sourcepath::String, depmods::Vector{Any})
│        @ Base .\loading.jl:944
│     [20] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64)
│        @ Base .\loading.jl:1028
│     [21] _require(pkg::Base.PkgId)
│        @ Base .\loading.jl:1315
│     [22] _require_prelocked(uuidkey::Base.PkgId)
│        @ Base .\loading.jl:1200
│     [23] macro expansion
│        @ .\loading.jl:1180 [inlined]
│     [24] macro expansion
│        @ .\lock.jl:223 [inlined]
│     [25] require(into::Module, mod::Symbol)
│        @ Base .\loading.jl:1144
│     [26] include(mod::Module, _path::String)
│        @ Base .\Base.jl:419
│     [27] exec_options(opts::Base.JLOptions)
│        @ Base .\client.jl:303
│     [28] _start()
│        @ Base .\client.jl:522
│    in expression starting at C:\Users\Hossein Pourbozorg\.julia\packages\AbstractDifferentiation\o62DE\src\forwarddiff.jl:1
└ @ Requires C:\Users\Hossein Pourbozorg\.julia\packages\Requires\Z8rfN\src\require.jl:51
ChrisRackauckas commented 1 year ago

https://github.com/JuliaDiff/AbstractDifferentiation.jl/blob/c04c0338bd5cf31159febbaab9faba65566c6faa/src/forwarddiff.jl this is dangerous. We should require the libraries that are used.

@devmotion can you make sure this is handled in https://github.com/JuliaDiff/AbstractDifferentiation.jl/pull/68 ?

devmotion commented 1 year ago

68 should be fine, StaticArrays is not loaded in the ForwardDiff backend in that PR. I had already removed it since it seemed to be unnecessary. I opened #75 as a fix.