JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.1k stars 214 forks source link

`eval` in OptimMOIExt fails to precompile #1087

Closed ven-k closed 3 months ago

ven-k commented 3 months ago
fatal: error thrown and no exception handler available.
InitError(mod=:OptimMOIExt, error=ErrorException("Evaluation into the closed module `Optim` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `Optim` with `eval` during precompilation - don't do this."))

MWE: With a optim-test/OptimTest.jl file that has:


module OptimTest

using MathOptInterface
using Optim

end
pushfirst!(LOAD_PATH, "optim-test")
using OptimTest
theogf commented 3 months ago

For v1.9+ the solution is to use setglobal! I suppose, but what about v1.8- ?

devmotion commented 3 months ago

I think the easiest is just to keep MOI as a regular dependency on Julia < 1.9: https://github.com/JuliaNLSolvers/Optim.jl/pull/1088