VScode Julia REPL "path" issue (while bash works fine)

Hi all,

I’m trying to use the Julia REPL but having a library path problem.
Oddly, the same code works just fine with bash/terminal (right-hand side), but an error occurs with REPL (left-hand side):
Can anyone let me know how to resolve this issue?

shell> pwd
/Users/jipkim/Dropbox/Julia/JuMP_examples

julia> include("test_Gurobi.jl")
ERROR: LoadError: could not load library "libgurobi91.dylib"
dlopen(libgurobi91.dylib, 1): image not found
Stacktrace:
  [1] GRBloadenv
    @ ~/.julia/packages/Gurobi/BAtIN/src/gen91/libgrb_api.jl:738 [inlined]
  [2] Gurobi.Env()
    @ Gurobi ~/.julia/packages/Gurobi/BAtIN/src/MOI_wrapper/MOI_wrapper.jl:102
  [...]
in expression starting at /Users/jipkim/Dropbox/Julia/JuMP_examples/test_Gurobi.jl:2

Here is the simple JuMP code (test_Gurobi.jl) :

using JuMP, Gurobi
m = Model(Gurobi.Optimizer)
@variable(m, x <= 5)
@objective(m, Max, x)
JuMP.optimize!(m)
@show JuMP.termination_status(m)

and here is my environment:

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
(@v1.6) pkg> status
      Status `~/.julia/environments/v1.6/Project.toml`
  [7c4d4715] AmplNLWriter v0.7.2
  [c52e3926] Atom v0.12.33
  [a076750e] CPLEX v0.7.7
  [336ed68f] CSV v0.8.5
  [aaaa29a8] Clustering v0.14.2
  [a93c6f00] DataFrames v1.2.2
  [31c24e10] Distributions v0.25.11
  [1ca51c6a] GAMS v0.2.4
  [2e9cd046] Gurobi v0.9.14
  [f67ccb44] HDF5 v0.15.6
  [7073ff75] IJulia v1.23.2
  [b6b21f68] Ipopt v0.7.0
  [4076af6c] JuMP v0.21.9
  [e5e0dc1b] Juno v0.8.4
  [67920dd8] KNITRO v0.10.0
  [23992714] MAT v0.10.1
  [6405355b] Mosek v1.1.3
  [1ec41992] MosekTools v0.9.4
  [a8b11937] OpenDSSDirect v0.7.2
  [91a5bcdd] Plots v1.20.0
  [c36e90e8] PowerModels v0.18.2
  [c946c3f1] SCS v0.7.1
  [29cba6d7] Bonmin_jll v100.800.800+0
  [8bb1440f] DelimitedFiles
1 Like

Are these using the same environment? What happens if you import Pkg; Pkg.build("Gurobi") in the REPL before running the script?

Otherwise I’m not sure what the problem is. VS Code is probably mangling things on their side.

cc @davidanthoff may have insight.

2 Likes

@odow Thank you for your reply. Yes, I have only one Julia version installed on my mac.

Here is what I get when I ran Pkg.build("Gurobi") on the VScode Julia REPL:

julia> Pkg.build("Gurobi")
    Building Gurobi → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/aac05324d46b53289ccb05510b05b4a56ffd3ed5/build.log`
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/jump-dev/Gurobi.jl and post the full
print-out of this diagnostic attempt.

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ ~/.julia/packages/Gurobi/BAtIN/deps/build.jl:165
 [3] include(fname::String)
   @ Base.MainInclude ./client.jl:444
 [4] top-level scope
   @ none:5
in expression starting at /Users/jipkim/.julia/packages/Gurobi/BAtIN/deps/build.jl:159

**Unable to locate Gurobi installation. Running some common diagnostics.**

Gurobi.jl only supports the following versions:

 - gurobi91
 - gurobi90

Did you download and install one of these versions from gurobi.com?
Installing Gurobi.jl via the Julia package manager is _not_ sufficient!

As a matter of fact, it is not only GUROBI but also Ipopt+HSL. They work well on the bash terminal, but VScode REPL returns an error message (e.g. dlopen(libhsl.dylib, 2): image not found).

Following up on this issue:

I just found out that, Julia REPL enters a different environment as soon as I start it by (cmd + shift + p -> Julia: Start REPL). Then it is on “(directory name)” environment, not “(@v1.6)”

On Julia REPL, if I type ] and status, then:

(JuMP_examples) pkg> status
      Status `~/Dropbox/Julia/JuMP_examples/Project.toml` (empty project)

On regular terminal, if I type ] and status, then:

(@v1.6) pkg> status
      Status `~/.julia/environments/v1.6/Project.toml`
  [7c4d4715] AmplNLWriter v0.7.2
  [aaaa29a8] Clustering v0.14.2
  [a93c6f00] DataFrames v1.2.2
  [31c24e10] Distributions v0.25.11
  [191a621a] Dualization v0.3.4
  [2e9cd046] Gurobi v0.9.14
  [7073ff75] IJulia v1.23.2
  [b6b21f68] Ipopt v0.7.0
  [4076af6c] JuMP v0.21.9
  [67920dd8] KNITRO v0.10.0
  [23992714] MAT v0.10.1
  [6405355b] Mosek v1.1.3
  [1ec41992] MosekTools v0.9.4
  [f10290a3] NEOSServer v0.4.0
  [a8b11937] OpenDSSDirect v0.7.2
  [c36e90e8] PowerModels v0.18.2
  [6e471128] PowerModelsAnnex v0.7.1
  [c946c3f1] SCS v0.7.1
  [29cba6d7] Bonmin_jll v100.800.800+0
  [8ba89e20] Distributed

I’m experiencing this on my both macs.