# Error finding shared libraries when running executable

**URL:** <https://discourse.julialang.org/t/error-finding-shared-libraries-when-running-executable/87230>\
**Category:** General Usage\
**Tags:** question, run\
**Created:** [September 13, 2022, 7:07pm UTC](https://discourse.julialang.org/t/error-finding-shared-libraries-when-running-executable/87230 "2022-09-13T19:07:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon22248738](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@anon22248738](https://discourse.julialang.org/u/anon22248738)\
**Post date:** [September 13, 2022, 7:07pm UTC](https://discourse.julialang.org/t/error-finding-shared-libraries-when-running-executable/87230/1 "2022-09-13T19:07:38Z")

</div>

I’m trying to call a executable from Julia using the run() command but am having some issues.I have a command that calls a Fortran executable with a number of arguments `exe --flag arg --flag2 arg` and I can successfully run this command from both the command line and the terminal inside of VSCode however when I call `run(`bash -c exe --flag arg --flag2 arg`)`

I get an error that one of the .so libraries is not found: `error while loading shared libraries: example.so: cannot open shared object file: No such file or directory` I have tried adding the library to the $PATH variable inside of julia but when I call `run(`echo $PATH`)` I get that the variable is not defined.

What am I missing in my understanding of how the run() command works? If anyone could help I’d appreciate it

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 13, 2022, 7:23pm UTC](https://discourse.julialang.org/t/error-finding-shared-libraries-when-running-executable/87230/2 "2022-09-13T19:23:59Z")

</div>

First, `run(`echo $PATH`)` will not work: that is [interpolating](https://docs.julialang.org/en/v1/manual/running-external-programs/#command-interpolation) a _Julia_ variable named `PATH` into the arguments used for launching `echo`, which fails since you haven’t (and shouldn’t) define a Julia variable named `PATH`.

(Realize that `run` is _not_ launching a shell (like bash) and then passing it a string, it’s instead spawning programs directly. If you want a shell command, you have to launch the shell yourself, e.g. via `run(`bash -c "echo \$PATH"`)`.)

What you want to make sure the path [environment variables](https://docs.julialang.org/en/v1/manual/environment-variables/#Environment-Variables) are set correctly. For example, you can check the `PATH` environment variable in Julia with `ENV["PATH"]` (without using `run`). However, if you are opening `.so` files I’m guessing you are on a Unix variant, in which case the relevant environment variable is `LD_LIBRARY_PATH` (which tells the runtime linker where to find shared libraries), not `PATH` (which tells the shell where to find executables).

---

<div class="post-metadata">

**Author:** ![anon22248738](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@anon22248738](https://discourse.julialang.org/u/anon22248738)\
**Post date:** [September 13, 2022, 7:52pm UTC](https://discourse.julialang.org/t/error-finding-shared-libraries-when-running-executable/87230/3 "2022-09-13T19:52:10Z")

</div>

Adding the folder of .so files to the LD\_LIBRARY\_PATH worked. Thank you so much for helping clear this up.
