# Gurobi on Julia 1.4

**URL:** https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131
**Category:** Optimization (Mathematical)
**Created:** [June 26, 2020, 9:19pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131 "2020-06-26T21:19:11Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [June 26, 2020, 9:19pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/1 "2020-06-26T21:19:11Z")

</div>

I’m trying to upgrade Julia to 1.4 from 1.3, but Gurobi package is giving me the following error.  
Could anybody confirm whether it’s related to my own setting or not? Any comments would be appreciated.

I only have three packages installed:

```julia
(@v1.4) pkg> status
Status `~/.julia/environments/v1.4/Project.toml`
  [c52e3926] Atom v0.12.15
  [4076af6c] JuMP v0.21.3
  [e5e0dc1b] Juno v0.8.2

```

When I try to add Gurobi, it gives me the following error:

```julia
(@v1.4) pkg> add Gurobi
   Updating registry at `~/.julia/registries/General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
  Installed MathProgBase ─ v0.7.8
  Installed Gurobi ─────── v0.8.1
   Updating `~/.julia/environments/v1.4/Project.toml`
  [2e9cd046] + Gurobi v0.8.1
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [2e9cd046] + Gurobi v0.8.1
  [fdba3010] + MathProgBase v0.7.8
   Building Gurobi → `~/.julia/packages/Gurobi/7YNJV/deps/build.log`
┌ Error: Error building `Gurobi`:
│ Gurobi Optimizer version 9.0.2 build v9.0.2rc0 (mac64)
│ Copyright (c) 2020, Gurobi Optimization, LLC
│ ERROR: LoadError: Unable to locate Gurobi installation. If the advice above did not help,
│ open an issue at https://github.com/JuliaOpt/Gurobi.jl and post the full
│ print-out of this diagnostic attempt.
│
│ Stacktrace:
│ [1] error(::String) at ./error.jl:33
│ [2] top-level scope at /Users/singingkim/.julia/packages/Gurobi/7YNJV/deps/build.jl:154
│ [3] include(::String) at ./client.jl:439
│ [4] top-level scope at none:5
│ in expression starting at /Users/singingkim/.julia/packages/Gurobi/7YNJV/deps/build.jl:152
│ Unable to locate Gurobi installation. Running some common diagnostics.
│
│ Gurobi.jl only supports the following versions:
│
│ - gurobi90
│ - gurobi81
│ - gurobi80
│ - gurobi75
│ - gurobi70
│
│ Did you download and install one of these versions from gurobi.com?
│
│
│ Looking for a version of Gurobi in your path:
│
│
│ We couldn't find the `GUROBI_HOME` environment variable, but we
│ found this version of Gurobi on your path. Is this version one of
│ the supported versions listed above? If not, you should edit your
│ `PATH` to point to the correct version.
└ @ Pkg.Operations /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:899

```

---

<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: [June 26, 2020, 9:35pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/2 "2020-06-26T21:35:57Z")

</div>

That is super weird. It looks like it found Gurobi but then it didn’t?

Where is your Gurobi installed? Try setting the `GUROBI_HOME` environment variable to `/Library/gurobi902/mac64` (or equivalent, depending on where you installed it).

What is the output of

```nohighlight
using Libdl
Libdl.dlopen("libgurobi90.dylib")

```

---

<div class="post-metadata">

### Author: ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)
#### Post date: [June 26, 2020, 9:36pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/3 "2020-06-26T21:36:01Z")

</div>

I just tried and got almost the same error, but in my case I don’t see any traces of downloading/building Gurobi (see below)

@SingingKim can you try to download it from [gurobi.com](http://gurobi.com) manually?

```julia
┌ Error: Error building `Gurobi`:
│ ERROR: LoadError: Unable to locate Gurobi installation. If the advice above did not help,
│ open an issue at https://github.com/JuliaOpt/Gurobi.jl and post the full
│ print-out of this diagnostic attempt.
│
│ Stacktrace:
│ [1] error(::String) at /Applications/Julia-1.4.app/Contents/Resources/julia/lib/julia/sys.dylib:?
│ [2] top-level scope at /Users/tamasgal/.julia/packages/Gurobi/7YNJV/deps/build.jl:154
│ [3] include(::String) at /Applications/Julia-1.4.app/Contents/Resources/julia/lib/julia/sys.dylib:?
│ [4] top-level scope at none:5
│ in expression starting at /Users/tamasgal/.julia/packages/Gurobi/7YNJV/deps/build.jl:152
│ Unable to locate Gurobi installation. Running some common diagnostics.
│ Gurobi.jl only supports the following versions:
│
│ - gurobi90
│ - gurobi81
│ - gurobi80
│ - gurobi75
│ - gurobi70
│
│ Did you download and install one of these versions from gurobi.com?

```

---

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [June 26, 2020, 10:33pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/4 "2020-06-26T22:33:44Z")

</div>

It’s very odd as it works just fine on Julia 1.3.  
Can you let me know how to set an environment variable?

Gurobi installation location: `/Library/gurobi902/`

```julia
julia> using Libdl

julia> Libdl.dlopen("libgurobi90.dylib")
ERROR: could not load library "libgurobi90.dylib"
dlopen(libgurobi90.dylib, 1): image not found
Stacktrace:
 [1] dlopen(::String, ::UInt32; throw_error::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Libdl/src/Libdl.jl:109
 [2] dlopen at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Libdl/src/Libdl.jl:109 [inlined] (repeats 2 times)
 [3] top-level scope at REPL[10]:1

```

---

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [June 26, 2020, 10:36pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/5 "2020-06-26T22:36:07Z")

</div>

Yes, I downloaded Gurobi from their webpage and added my license key.

---

<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: [June 26, 2020, 10:58pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/6 "2020-06-26T22:58:27Z")

</div>

Try

```nohighlight
ENV["GUROBI_HOME"] = "/Library/gurobi902/mac64"
] build Gurobi

```

---

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [June 26, 2020, 11:20pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/7 "2020-06-26T23:20:53Z")

</div>

It worked! Thanks a lot for helping me.

---

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [June 27, 2020, 12:04am UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/8 "2020-06-27T00:04:06Z")

</div>

Oscar, let me ask you one more similar question.

Ipopt with HSL gives me the following error:

```julia
using JuMP, Ipopt
m = Model(Ipopt.Optimizer)
set_optimizer_attribute(m, "linear_solver", "ma86")
@variable(m, x <= 5)
JuMP.optimize!(m)

```

```julia
Exception of type: OPTION_INVALID in file "IpAlgBuilder.cpp" at line 349:
 Exception message: Selected linear solver HSL_MA86 not available.
Tried to obtain HSL_MA86 from shared library "libhsl.dylib", but the following error occured:
dlopen(libhsl.dylib, 2): image not found

```

However, it also works fine with Julia 1.3.  
(Your renaming solution (libcoinhsl.dylib-\>libhsl.dylib) fixed my previous issue with Julia 1.3.).

Do you have any idea how to fix this for Julia 1.4?

---

<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: [June 27, 2020, 4:20pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/9 "2020-06-27T16:20:26Z")

</div>

No, I don’t know. You need to have the `libhsl.dylib` library somewhere you can `dlopen` it. I’m not sure why changing from 1.3 to 1.4 would change that.

---

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [June 27, 2020, 8:35pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131/10 "2020-06-27T20:35:48Z")

</div>

I see. Thanks for your help!
