"could not load library" problem from inside Juno

I am an enthusiastic julia newbie. I was trying to run ArrayFire (i.e., use the GPU with Julia). After downloading and installing ArrayFire and ArrayFire.jl, it worked in Julia running from the command line, but not through Atom/Juno.

From the command line it worked because I added setenv LD_LIBRARY_PATH /opt/arrayfire/lib to my .tcshrc (yes, people still use it).

For juno, I added

ENV["LD_LIBRARY_PATH"] = "/opt/arrayfire/lib"
ENV["DYLD_LIBRARY_PATH"] = "/opt/arrayfire/lib"

to .julia/config/startup.jl

When running Julia through Juno ENV does show that the above were set, however, the commands:

using ArrayFire 
a = rand(AFArray{Float64},100,100)

produce the error

ERROR: error compiling rand: could not load library "libaf.3"
dlopen(libaf.3.dylib, 1): image not found

I’m a bit clueless… how do I force Juno to be aware of the library?
Any suggestions will be appreciated (especially if they will resolve the problem :wink: )

More about the system
Mac Book Pro running OS X 10.15.3
Julia Version 1.3.1
Atom version 1.45.0
julia-client 0.12.3

Thanks!
– Nir

Out of curiosity have you tried logging out and logging back in? Or maybe launching atom from a terminal? Setting LD_LIBRARY_PATH in. tschrc should also affect the environment of Atom (and it’s child processes), assuming atom was started from a process that had that environment variable set.

I tried running Atom from the command line, logging out and even rebooting for good measure. Didn’t work.

I should add that sometimes running using ArrayFire produces the library finding error:

julia> using ArrayFire
ERROR: InitError: error compiling __init__: could not load library "libaf.3"
dlopen(libaf.3.dylib, 1): image not found
Stacktrace:
 [1] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:692
 [2] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:776
 [3] _require(::Base.PkgId) at ./loading.jl:1001
 [4] require(::Base.PkgId) at ./loading.jl:922
 [5] require(::Module, ::Symbol) at ./loading.jl:917
during initialization of module ArrayFire

Can you try putting

process.env["LD_LIBRARY_PATH"] = "/opt/arrayfire/lib"
process.env["DYLD_LIBRARY_PATH"] = "/opt/arrayfire/lib"

into Atom’s init script (press Cmd-Shift-P and type in init script)?

Bingo! This did it. Thanks! :smiley:

It works for my solver in Ipopt for JuMP too! This

Hi, is it possible to implement in the similar way in VScode? I am migrating from Atom to VScode Julia