Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Julia 1.10, NLoptMathOptInterfaceExt errors on load #210

Closed
BioTurboNick opened this issue Dec 27, 2023 · 9 comments · Fixed by #211
Closed

In Julia 1.10, NLoptMathOptInterfaceExt errors on load #210

BioTurboNick opened this issue Dec 27, 2023 · 9 comments · Fixed by #211

Comments

@BioTurboNick
Copy link

BioTurboNick commented Dec 27, 2023

While loading NLopt in Julia 1.10, I got this error:

│  ┌ Error: Error during loading of extension NLoptMathOptInterfaceExt of NLopt, use `Base.retry_load_extensions()` to retry.
│  │   exception =
│  │    1-element ExceptionStack:
│  │    InitError: Creating a new global in closed module `NLopt` (`Optimizer`) breaks incremental compilation because the side effects will not be permanent.
│  │    Stacktrace:
│  │      [1] __init__()
│  │        @ NLoptMathOptInterfaceExt ~/.julia/packages/NLopt/1EJXl/ext/NLoptMathOptInterfaceExt.jl:17
│  │      [2] run_module_init(mod::Module, i::Int64)
│  │        @ Base ./loading.jl:1128
│  │      [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
│  │        @ Base ./loading.jl:1116
│  │      [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
│  │        @ Base ./loading.jl:1061
│  │      [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
│  │        @ Base ./loading.jl:1575
│  │      [6] _require(pkg::Base.PkgId, env::Nothing)
│  │        @ Base ./loading.jl:1932
│  │      [7] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│  │        @ Base ./loading.jl:1806
│  │      [8] #invoke_in_world#3
│  │        @ Base ./essentials.jl:921 [inlined]
│  │      [9] invoke_in_world
│  │        @ Base ./essentials.jl:918 [inlined]
│  │     [10] _require_prelocked
│  │        @ Base ./loading.jl:1797 [inlined]
│  │     [11] _require_prelocked
│  │        @ Base ./loading.jl:1796 [inlined]
│  │     [12] run_extension_callbacks(extid::Base.ExtensionId)
│  │        @ Base ./loading.jl:1289
│  │     [13] run_extension_callbacks(pkgid::Base.PkgId)
│  │        @ Base ./loading.jl:1324
│  │     [14] run_package_callbacks(modkey::Base.PkgId)
│  │        @ Base ./loading.jl:1158
│  │     [15] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::String, sourcepath::String, depmods::Vector{Any})
│  │        @ Base ./loading.jl:1481
│  │     [16] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
│  │        @ Base ./loading.jl:1568
│  │     [17] _require(pkg::Base.PkgId, env::String)
│  │        @ Base ./loading.jl:1932
│  │     [18] __require_prelocked(uuidkey::Base.PkgId, env::String)
│  │        @ Base ./loading.jl:1806
│  │     [19] #invoke_in_world#3
│  │        @ Base ./essentials.jl:921 [inlined]
│  │     [20] invoke_in_world
│  │        @ Base ./essentials.jl:918 [inlined]
│  │     [21] _require_prelocked(uuidkey::Base.PkgId, env::String)
│  │        @ Base ./loading.jl:1797
│  │     [22] macro expansion
│  │        @ Base ./loading.jl:1784 [inlined]
│  │     [23] macro expansion
│  │        @ Base ./lock.jl:267 [inlined]
│  │     [24] __require(into::Module, mod::Symbol)
│  │        @ Base ./loading.jl:1747
│  │     [25] #invoke_in_world#3
│  │        @ Base ./essentials.jl:921 [inlined]
│  │     [26] invoke_in_world
│  │        @ Base ./essentials.jl:918 [inlined]
│  │     [27] require(into::Module, mod::Symbol)
│  │        @ Base ./loading.jl:1740
│  │     [28] include(mod::Module, _path::String)
│  │        @ Base ./Base.jl:495
│  │     [29] include(x::String)
│  │        @ SingleMoleculeLocalization ~/.julia/packages/SingleMoleculeLocalization/7FZ8u/src/SingleMoleculeLocalization.jl:1
│  │     [30] top-level scope
│  │        @ ~/.julia/packages/SingleMoleculeLocalization/7FZ8u/src/SingleMoleculeLocalization.jl:17
│  │     [31] include
│  │        @ Base ./Base.jl:495 [inlined]
│  │     [32] 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, UInt128}}, source::Nothing)
│  │        @ Base ./loading.jl:2216
│  │     [33] top-level scope
│  │        @ stdin:3
│  │     [34] eval
│  │        @ Core ./boot.jl:385 [inlined]
│  │     [35] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│  │        @ Base ./loading.jl:2070
│  │     [36] include_string
│  │        @ Base ./loading.jl:2080 [inlined]
│  │     [37] exec_options(opts::Base.JLOptions)
│  │        @ Base ./client.jl:316
│  │     [38] _start()
│  │        @ Base ./client.jl:552
│  │    during initialization of module NLoptMathOptInterfaceExt
│  └ @ Base loading.jl:1295
@stevengj
Copy link
Collaborator

cc @palday, who introduced the setglobal! call in #204

@palday
Copy link
Contributor

palday commented Dec 27, 2023

Huh, interesting. I have an idea about how to fix it - will report back later.

@palday
Copy link
Contributor

palday commented Dec 27, 2023

@BioTurboNick I can't replicate at the moment -- I tried things in a clean environment with just NLopt and MathOptInterface on 1.10 and can load both without problems. Can you share more about your environment?

@BioTurboNick
Copy link
Author

I managed to create a MWE test project that should reproduce the error when loaded with using testproj. Compiled cache may need to be cleared before loading.

testproj.zip

@palday
Copy link
Contributor

palday commented Dec 28, 2023

thanks @BioTurboNick ! That shows it off even without clearing my precompilation cache -- it appears the problem first arises when everything is further wrapped in a module that gets precompiled.

@palday
Copy link
Contributor

palday commented Dec 28, 2023

@BioTurboNick I think #211 fixes it. You can install it with pkg> add https://github.com/palday/NLopt.jl#pa/setglobal

@BioTurboNick
Copy link
Author

Seems to work, thanks! I wonder if Julia should be erroring at the REPL for the previous version, or at least emitting a warning?

@palday
Copy link
Contributor

palday commented Dec 28, 2023

I'm wondering if it's not a problem in the REPL because of the way precompilation works there -- you don't compile all of module Main at the same time like you do for a package's module.

@bclyons12
Copy link

I'm running into this problem frequently, usually requiring a restart of my REPL. Hopefully the fix will released soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants