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

**URL:** <https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853>\
**Category:** New to Julia\
**Tags:** question, package, precompilation, modelingtoolkit\
**Created:** [January 12, 2023, 8:44am UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853 "2023-01-12T08:44:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Hebing](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lukas_hebing/32/45778_2.png) [@Lukas\_Hebing](https://discourse.julialang.org/u/Lukas_Hebing)\
**Post date:** [January 12, 2023, 8:44am UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853/1 "2023-01-12T08:44:30Z")

</div>

Hello,

as suggested [in the pkg dodumentation](https://pkgdocs.julialang.org/v1/environments/), 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
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

```

---

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [January 12, 2023, 8:54am UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853/2 "2023-01-12T08:54:43Z")

</div>

Try deleting the `Manifest.toml` file and run

```julia
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.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 12, 2023, 8:56am UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853/3 "2023-01-12T08:56:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Lukas\_Hebing](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lukas_hebing/32/45778_2.png) [@Lukas\_Hebing](https://discourse.julialang.org/u/Lukas_Hebing)\
**Post date:** [January 12, 2023, 5:43pm UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853/4 "2023-01-12T17:43:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lukas\_Hebing](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lukas_hebing/32/45778_2.png) [@Lukas\_Hebing](https://discourse.julialang.org/u/Lukas_Hebing)\
**Post date:** [January 12, 2023, 5:45pm UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853/5 "2023-01-12T17:45:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Salmon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salmon/32/22968_2.png) [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Post date:** [January 12, 2023, 8:20pm UTC](https://discourse.julialang.org/t/unable-to-re-create-an-environment-pre-compile-errors/92853/6 "2023-01-12T20:20:15Z")

</div>

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 🤷‍♀️
