ModelingToolkit fails to precompile on Julia 1.12 (UndefVarError: ODESystem not defined in ModelingToolkit)

Hi everyone,

I’m having trouble with ModelingToolkit precompilation on Julia 1.12 on Windows, and I can’t figure out what’s triggering it.

In my project I’m just adding some libraries (including ModelingToolkit) :

using ModelingToolkit
using OrdinaryDiffEq
using Plots
using Waveforms
using Sundials
using DASSL

and I consistently get:

PkgPrecompileError: The following 1 direct dependency failed to precompile:

ModelingToolkit


Failed to precompile ModelingToolkit [961ee093-0014-501f-94e3-6117800e7a78] to "C:\\Users\\...\\.julia\\compiled\\v1.12\\ModelingToolkit\\jl_XXXX.tmp".
ERROR: LoadError: UndefVarError: `ODESystem` not defined in `ModelingToolkit`
Suggestion: define the const at top-level before running function that uses it (stricter Julia v1.12+ rule).

I tried to add a local environment and compile via:

using Pkg
Pkg.activate(@__DIR__)
Pkg.instantiate()
Pkg.precompile()

but I still get the same error.

Some extras :

Using ModelingToolkit in the REPL works, so it seems the package itself is installed, but the precompilation step keeps failing with this ODESystem error.

Has anyone seen this on Julia 1.12, or knows what can cause this issue during precompile? Any tips on how to debug which file / expression is being evaluated at that point would be very welcome.

Thanks!

Hi,
can you maybe post the Project.toml and Mainifest.toml?

Somehow I seems to work on my machine, if I just install the packages, so maybe it has to do with specific versions.

ODESystem doesn’t exist in the ModelingToolkit versions that came out in the last year, so this is at least clearly not on anything recent. What versions do you have? What in your Project.toml is keeping things back?