I want to set an environment variable LD_LIBRARY_PATH
which may or may not exist (it does not seem to exist currently, but I'm not sure if it will at some point).
I have successfully managed to set my own vars, and extend the PATH
variable as well, by placing my path.sh
into /etc/profile.d/
and that works fine, however this new variable just does not seem to work. I have tried extending it or seting it new, with and without if / else (see screenshot). No matter what I do, it simply won't be added to the environment variables and I have no idea why (since it worked before). I did reboot, so that should not be the issue
For easier reading, here is the path.sh
content in text form:
export PATH="$PATH:/snap/cmake/current/bin"
export unreal_path="/DevShared/UnrealEngine"
export GRPC_DIR="/DevShared/Dev_SRS/grpc/1.20.0"
export LD_LIBRARY_PATH="/DevShared/UnrealEngine"
#LD_LIBRARY_PATH may not exist
#ldPath="$unreal_path"
#if [ $LD_LIBRARY_PATH -z ]
#then
export LD_LIBRARY_PATH="$ldPath"
#else
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ldPath"
#fi
#echo $LD_LIBRARY_PATH
Note that if I call the script via sudo bash /etc/profile.d/path.sh
with the latter part executing rather than commented out, the bash actually does echo the correct path. Also, that ldPath
variable was just for testing purposes, it is not actually necessary.