# Julia not finding it's own artifacts

**URL:** <https://discourse.julialang.org/t/julia-not-finding-its-own-artifacts/91863>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 19, 2022, 4:39pm UTC](https://discourse.julialang.org/t/julia-not-finding-its-own-artifacts/91863 "2022-12-19T16:39:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndusek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndusek/32/45220_2.png) [@ndusek](https://discourse.julialang.org/u/ndusek)\
**Post date:** [December 19, 2022, 4:39pm UTC](https://discourse.julialang.org/t/julia-not-finding-its-own-artifacts/91863/1 "2022-12-19T16:39:42Z")

</div>

I am trying to run `Circuitscape` using Julia (v1.7.2) via the `JuliaCall` package in R and am getting the following error (as reported from within R):

```julia
Error: Error happens in Julia.
InitError: could not load library "/home/ndusek/.julia/artifacts/e4afa6442d82c9e3819067808b91aa8308d90db6/lib/libgeotiff.so"
libproj.so.25: cannot open shared object file: No such file or directory
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:117
  [2] dlopen(s::String, flags::UInt32)
    @ Base.Libc.Libdl ./libdl.jl:117
  [3] macro expansion
    @ ~/.julia/packages/JLLWrappers/QpMQW/src/products/library_generators.jl:54 [inlined]
  [4] __init__ ()
    @ libgeotiff_jll ~/.julia/packages/libgeotiff_jll/EG4x2/src/wrappers/x86_64-linux-gnu.jl:15
  [5] _include_from_serialized(path::String, depmods::Vector{Any})
    @ Base ./loading.jl:768
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
    @ Base ./loading.jl:854
  [7] _tryrequire_from_serialized(modkey::Base.PkgId, build_id::UInt64, modpath::String)
    @ Base ./loading.jl:783
  [8] _require_search_from_seriali

```

From the above, I understand that `libgeotiff.so` is trying to load `libproj.so.25` and is not able to find it. However, I can see that Julia has an artifact for `libproj.so.25` by doing a `find`:

```julia
$ find ~/.julia/artifacts -name libproj.so.25
/home/ndusek/.julia/artifacts/8a643038d2adde781829b4467a32afa307e23b51/lib/libproj.so.25

```

Why is it that Julia is unable to find it’s own copy of the library? Do I need to set some environment variable to tell Julia to use it’s own artifacts to resolve recursive library dependencies?

As an added piece of information, I am running this inside the [Rocker project’s](https://rocker-project.org/images/) R geospatial container, so all of these geospatial libraries are available at the system level. But evidently, Julia prefers to install it’s own copy of each library.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 19, 2022, 4:59pm UTC](https://discourse.julialang.org/t/julia-not-finding-its-own-artifacts/91863/2 "2022-12-19T16:59:24Z")

</div>

> [@ndusek](#):
>
> Why is it that Julia is unable to find it’s own copy of the library?

I don’t know, ask your operating system which is hiding the answer from you: almost all operating systems are very bad in this regard, surprising only recent versions of macOS provide more information than absolutely nothing.

That said, do you have the `LD_LIBRARY_PATH` environment variable set? From within Julia you can see that with

```julia
ENV["LD_LIBRARY_PATH"]

```

In any case, if you want to know _why_ the library can’t be found, you can export the environment variable `LD_DEBUG=all` before starting julia, and when it’ll try to dlopen `libgeotiff.so` you should get some messages about what is being searched. Note: `LD_DEBUG=all` will print _ **a lot** _ of text to standard error, you may want to redirect it to file to analyze it later.

---

<div class="post-metadata">

**Author:** ![ndusek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndusek/32/45220_2.png) [@ndusek](https://discourse.julialang.org/u/ndusek)\
**Post date:** [December 19, 2022, 5:15pm UTC](https://discourse.julialang.org/t/julia-not-finding-its-own-artifacts/91863/3 "2022-12-19T17:15:56Z")

</div>

Hi @giordano, thanks for the quick reply and for being patient with me.

What you’ve described is what I would normally do, i.e. add the lib dir to `LD_LIBRARY_PATH`. In this case, I assumed since Julia was installing libraries in `~/.julia/artifacts` that adding `$JULIA_HOME/lib` to the `LD_LIBRARY_PATH` wouldn’t do the trick. But in fact, it did (_mea culpa_).

So there must be some magic Julia is doing behind the scenes whereby adding Julia’s global lib dir to `LD_LIBRARY_PATH` in turn links all the libs in `~/.julia/artifacts`?

In any case, the original error is resolved after making that chance. Now I’m getting errors from GDAL, but I think these might be related to the interop with R and not Julia per se.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 19, 2022, 5:29pm UTC](https://discourse.julialang.org/t/julia-not-finding-its-own-artifacts/91863/4 "2022-12-19T17:29:16Z")

</div>

> [@ndusek](#):
>
> What you’ve described is what I would normally do, i.e. add the lib dir to `LD_LIBRARY_PATH`. In this case, I assumed since Julia was installing libraries in `~/.julia/artifacts` that adding `$JULIA_HOME/lib` to the `LD_LIBRARY_PATH` wouldn’t do the trick. But in fact, it did (_mea culpa_).
> 
> So there must be some magic Julia is doing behind the scenes whereby adding Julia’s global lib dir to `LD_LIBRARY_PATH` in turn links all the libs in `~/.julia/artifacts`?

There isn’t much magic involved, but if your `LD_LIBRARY_PATH` wasn’t empty (or with some non-julia libraries taking precedence over julia directories), julia may have mixed up some libraries causing troubles down the line. I generally recommend starting Julia with an empty `LD_LIBRARY_PATH` if possible, in that way you avoid mixing up julia’s libraries with system libraries.
