Reputation: 2476
In my .zshrc
file I have the following line:
export LD_LIBRARY_PATH='~/.local/lib'
I can confirm that the variable has been set correctly by echoing the variable from the command line:
> echo $LD_LIBRARY_PATH
~/.local/lib
I have a program that requires a library, foo.so.1
, found in this local lib directory. Running directly from the command line fails:
> bar -v 123
bar: error when loading shared libraries: foo.so.1: cannot open shared object file: No such file or directory
However, if I set LD_LIBRARY_PATH manually before running the command everything works fine:
> LD_LIBRARY_PATH=~/.local/lib bar -v 123
Success!
My question is: why does setting the variable immediately before running the command work, while setting it in .zshrc
fails?
Upvotes: 1
Views: 2075
Reputation: 4023
Please ensure your env variable gets assigned the path with "~" being expanded to your home directory as such expansion will not take place when the variable is being read.
Your (revised) code uses single quotes. Those will prevent expansion from taking place.
Upvotes: 2