Unable to re-create an environment: Pre-compile errors

Hello,

as suggested in the pkg dodumentation, I tried to use an existing project.toml and manifest.toml file to re-create an anvironment of a colleague. Installing runs fine. However, when I use some packages (e.g. ModelingToolkit), I get errors on precompilation. Others run fine. I am getting stuck googling the error messages. Am I doing something wrong?

julia> using ModelingToolkit
[ Info: Precompiling ModelingToolkit [961ee093-0014-501f-94e3-6117800e7a78]
ERROR: LoadError: UndefVarError: StandardNonlinearProblem not defined
Stacktrace:
 [1] include
   @ .\Base.jl:418 [inlined]
 [2] 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:1318
 [3] top-level scope
   @ none:1
 [4] eval
   @ .\boot.jl:373 [inlined]
 [5] eval(x::Expr)
   @ Base.MainInclude .\client.jl:453
 [6] top-level scope
   @ none:1
in expression starting at C:\Users\GDIWT\.julia\packages\ModelingToolkit\oE1IR\src\ModelingToolkit.jl:1
ERROR: Failed to precompile ModelingToolkit [961ee093-0014-501f-94e3-6117800e7a78] to C:\Users\GDIWT\.julia\compiled\v1.7\ModelingToolkit\jl_8A64.tmp.
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
    @ Base .\loading.jl:1466
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1410
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1120
  [5] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1013
  [6] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:997
  [7] eval
    @ .\boot.jl:373 [inlined]
  [8] eval
    @ .\Base.jl:68 [inlined]
  [9] repleval(m::Module, code::Expr, #unused#::String)
    @ VSCodeServer c:\Users\GDIWT\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:222
 [10] (::VSCodeServer.var"#107#109"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer c:\Users\GDIWT\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:186
 [11] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:511
 [12] with_logger
    @ .\logging.jl:623 [inlined]
 [13] (::VSCodeServer.var"#106#108"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer c:\Users\GDIWT\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:187
 [14] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [15] invokelatest(::Any)
    @ Base .\essentials.jl:714
 [16] macro expansion
    @ c:\Users\GDIWT\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
 [17] (::VSCodeServer.var"#61#62")()
    @ VSCodeServer .\task.jl:429

Try deleting the Manifest.toml file and run

using Pkg
Pkg.activate(".") # make sure you are in the right folder
Pkg.instantiate()

EDIT: You may only need to run Pkg.instantiate() and keeping the manifest, as this installs everything.

Although that would not guarantee that you are reproducing the same environment, as the project will get re-resolved - OP might be insterested in recreating the environment exactly.

Are you using the same Julia version as your colleague who created the manifest?

Thanks for the reply. Unfortunately, that`s exactly what I did

Thanks, that solved the issue!
I thought, that Julia versions were also managed by the package manager, but it seems that this something one has to care of manually.

I think instead of deleting the manifest one can usually also update the packages.
For future reference:
I have also had this issue, and it tried to fix it without giving up the original environment. I believe I ultimately made it work somehow by copying the manifest, then deleting all packages in the environment, copying the contents of the original manifest back an instantiating. Quite hacky unfortunately and probably not guaranteed to work.
Don’t know if there is a better way unfortunately as this problem is hard to reproduce :woman_shrugging:

1 Like