I've recently had to compile a program (Riak) from source since they don't have a repo available for Ubuntu 16.04 yet.
I've compiled the program and copied it to /opt/riak where it works fine.
Since this program requires sudo privileges, I've decided to symlink /opt/riak/bin/riak to /usr/local/bin/riak instead of adding the variable to the path via a profile.d file (because in order to work with sudo I'd have to remove env_reset from /etc/sudoers which I rather not do).
The error I get is the following:
/usr/local/bin/riak: 8: .: Can't open /usr/local/bin/../lib/env.sh
Shouldn't the symlink execute the file from the original's working directory? Is there a way to make it work?
The error message is almost self explanatory. Apparently the
riak executable is trying to find a file called
env.sh using a path relative to its own, namely
../lib/env.sh. Originally, this would resolve to the following path:
/opt/riak/bin/../lib/env.sh, which is the same as
/opt/riak/lib/env.sh. But now is trying to find the file at
/usr/local/bin/../lib/env.sh which is the same as
/usr/local/lib/env.sh and obviously the file is not there.
You have the following options (in order of preference):
/optand invoke it from there
/optand create a small wrapper shell script in
/usr/local/binthat calls the original executable (see at the end of this post).
--prefix=/usr/local) so that it works from
I would recommend against option 3; I prefer to let the
/usr directory be managed by the distos package manager. If I have to compile something myself, I prefer to put it in a dedicated directory bellow
/opt. This way, if I want to remove it later on, I can just delete that directory.
Example wrapper script for option 2:
#!/bin/bash exec /opt/riak/bin/riak "$@"