# Gurobi fails to precompile

**URL:** <https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198>\
**Category:** Optimization (Mathematical)\
**Tags:** optimization, gurobi\
**Created:** [October 11, 2024, 2:06pm UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198 "2024-10-11T14:06:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bjhamli](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@bjhamli](https://discourse.julialang.org/u/bjhamli)\
**Post date:** [October 11, 2024, 2:06pm UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198/1 "2024-10-11T14:06:57Z")

</div>

I am trying to run a file, but when I try to run the code Gurobi fails to precompile. The error output is at the end of the post. I have tried the suggested fix in the output:

```julia
using Pkg; Pkg.instantiate()

```

but I still receive the error. If I try

```Julia
Gurobi.Env()

```

I get:

Set parameter Username  
Academic license - for non-commercial use only - expires 2025-01-30  
Gurobi.Env(Ptr{Nothing} @0x00007fbd87f6ce00, false, 0)

**Here is the error** I receive from running the code:

```Julia
Precompiling Gurobi...
Info Given Gurobi was explicitly requested, output will be shown live 
ERROR: LoadError: InitError: Artifact "Gurobi" was not found by looking in the paths:
  ~/.julia/artifacts/4f276549146c3ac663c68db6fc5496497cdbd50a
  ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/local/share/julia/artifacts/4f276549146c3ac663c68db6fc5496497cdbd50a
  ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/artifacts/4f276549146c3ac663c68db6fc5496497cdbd50a
Try `using Pkg; Pkg.instantiate()` to re-install all missing resources if the artifact is part of a package or call `Pkg.ensure_artifact_installed` (https://pkgdocs.julialang.org/v1/api/#Pkg.Artifacts.ensure_artifact_installed) if not.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] _artifact_str( __module__ ::Module, artifacts_toml::String, name::SubString{String}, path_tail::String, artifact_dict::Dict{String, Any}, hash::Base.SHA1, platform::Base.BinaryPlatforms.Platform, lazyartifacts::Any)
    @ Artifacts ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Artifacts/src/Artifacts.jl:588
  [3] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:1054
  [4] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:1051
  [5] macro expansion
    @ ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Artifacts/src/Artifacts.jl:717 [inlined]
  [6] find_artifact_dir()
    @ Gurobi_jll ~/.julia/packages/JLLWrappers/inPJn/src/wrapper_generators.jl:17
  [7] __init__ ()
    @ Gurobi_jll ~/.julia/packages/Gurobi_jll/QGjvN/src/wrappers/aarch64-apple-darwin.jl:17
  [8] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1336
  [9] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1324
 [10] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1213
 [11] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1169 [inlined]
 [12] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
    @ Base ./loading.jl:1975
 [13] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2435
 [14] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2300
 [15] #invoke_in_world#3
    @ ./essentials.jl:1088 [inlined]
 [16] invoke_in_world
    @ ./essentials.jl:1085 [inlined]
 [17] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2287
 [18] macro expansion
    @ ./loading.jl:2226 [inlined]
 [19] macro expansion
    @ ./lock.jl:273 [inlined]
 [20] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2183
 [21] #invoke_in_world#3
    @ ./essentials.jl:1088 [inlined]
 [22] invoke_in_world
    @ ./essentials.jl:1085 [inlined]
 [23] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2176
 [24] top-level scope
    @ ~/.julia/packages/Gurobi/8rQku/src/Gurobi.jl:17
 [25] include
    @ ./Base.jl:557 [inlined]
 [26] 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:2806
 [27] top-level scope
    @ stdin:4
during initialization of module Gurobi_jll
in expression starting at /Users/benjaminhamlin/.julia/packages/Gurobi/8rQku/src/Gurobi.jl:7
in expression starting at stdin:4
  ✗ SpecialFunctions
  ✗ CodecBzip2
  ✗ ForwardDiff
  ✗ MathOptInterface
  ✗ Gurobi
  0 dependencies successfully precompiled in 35 seconds. 59 already precompiled.

ERROR: LoadError: The following 1 direct dependency failed to precompile:

Gurobi 

Failed to precompile Gurobi [2e9cd046-0924-5485-92f1-d5272153d98b] to "/Users/benjaminhamlin/.julia/compiled/v1.11/Gurobi/jl_sVPxE9".
ERROR: LoadError: InitError: Artifact "Gurobi" was not found by looking in the paths:
  ~/.julia/artifacts/4f276549146c3ac663c68db6fc5496497cdbd50a
  ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/local/share/julia/artifacts/4f276549146c3ac663c68db6fc5496497cdbd50a
  ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/artifacts/4f276549146c3ac663c68db6fc5496497cdbd50a
Try `using Pkg; Pkg.instantiate()` to re-install all missing resources if the artifact is part of a package or call `Pkg.ensure_artifact_installed` (https://pkgdocs.julialang.org/v1/api/#Pkg.Artifacts.ensure_artifact_installed) if not.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] _artifact_str( __module__ ::Module, artifacts_toml::String, name::SubString{String}, path_tail::String, artifact_dict::Dict{String, Any}, hash::Base.SHA1, platform::Base.BinaryPlatforms.Platform, lazyartifacts::Any)
    @ Artifacts ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Artifacts/src/Artifacts.jl:588
  [3] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:1054
  [4] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:1051
  [5] macro expansion
    @ ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Artifacts/src/Artifacts.jl:717 [inlined]
  [6] find_artifact_dir()
    @ Gurobi_jll ~/.julia/packages/JLLWrappers/inPJn/src/wrapper_generators.jl:17
  [7] __init__ ()
    @ Gurobi_jll ~/.julia/packages/Gurobi_jll/QGjvN/src/wrappers/aarch64-apple-darwin.jl:17
  [8] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1336
  [9] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1324
 [10] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1213
 [11] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1169 [inlined]
 [12] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
    @ Base ./loading.jl:1975
 [13] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2435
 [14] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2300
 [15] #invoke_in_world#3
    @ ./essentials.jl:1088 [inlined]
 [16] invoke_in_world
    @ ./essentials.jl:1085 [inlined]
 [17] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2287
 [18] macro expansion
    @ ./loading.jl:2226 [inlined]
 [19] macro expansion
    @ ./lock.jl:273 [inlined]
 [20] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2183
 [21] #invoke_in_world#3
    @ ./essentials.jl:1088 [inlined]
 [22] invoke_in_world
    @ ./essentials.jl:1085 [inlined]
 [23] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2176
 [24] top-level scope
    @ ~/.julia/packages/Gurobi/8rQku/src/Gurobi.jl:17
 [25] include
    @ ./Base.jl:557 [inlined]
 [26] 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:2806
 [27] top-level scope
    @ stdin:4
during initialization of module Gurobi_jll
in expression starting at /Users/benjaminhamlin/.julia/packages/Gurobi/8rQku/src/Gurobi.jl:7
in expression starting at stdin:
in expression starting at /Users/benjaminhamlin/Visual_Studio/SDDP_Experiments/gurobi.jl:11
in expression starting at /Users/benjaminhamlin/Visual_Studio/SDDP_Experiments/BiObjectiveSDDP.jl:6

```

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 11, 2024, 6:09pm UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198/2 "2024-10-11T18:09:29Z")

</div>

See this post:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

In particular, please put the stack trace and other output into a Markdown code block.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [October 15, 2024, 3:19am UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198/3 "2024-10-15T03:19:51Z")

</div>

Hi @bjhamli welcome to the forum 😄

Your `Gurobi.Env()` command looks like you have Gurobi installed and working???

What is the output of `import Pkg; Pkg.status()`?

Uh’oh: I scrolled to the end and saw `BiObjectiveSDDP.jl:6`. We should discuss more… I don’t really recommend using this code.

---

<div class="post-metadata">

**Author:** ![bjhamli](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@bjhamli](https://discourse.julialang.org/u/bjhamli)\
**Post date:** [October 15, 2024, 11:32am UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198/4 "2024-10-15T11:32:41Z")

</div>

Hi. Thank you for the kind welcome.

The status output is:

```julia
~/.julia/environments/v1.11/Project.toml`
  [2e9cd046] Gurobi v1.3.1
  [f4570300] SDDP v1.8.1
  [9a3f8284] Random v1.11.0

```

Oh dear. How should I contact you to discuss this?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [October 16, 2024, 1:40am UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198/5 "2024-10-16T01:40:07Z")

</div>

Are you on a school or work network with a firewall? I don’t really understand how you’re getting the error message if you have Gurobi working?

> How should I contact you to discuss this?

I’ll DM you my email

---

<div class="post-metadata">

**Author:** ![bjhamli](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@bjhamli](https://discourse.julialang.org/u/bjhamli)\
**Post date:** [October 16, 2024, 1:45pm UTC](https://discourse.julialang.org/t/gurobi-fails-to-precompile/121198/6 "2024-10-16T13:45:18Z")

</div>

The university may have a firewall. I have tried it at home and received the same error. I am using a university owned machine, but I’ve had no problems with Gurobi in either Python or MATLAB on the same machine.

My advisor helped me work through it in our meeting today. I did not have a config folder in my .julia folder. We created the config folder, placed the project.toml file there, removed Gurobi, reinstalled it. Now everything seems to be working.
