Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding System Binaries With Home Directory Binaries

I'm trying to compile a piece of software in my home directory (OpenMPI). One of the build dependencies (autoconf) installed on my system is not the newer version asked for by the OpenMPI autogen script. I compiled and installed the newer version of autoconf in my home directory.

Is there anyway for the binary installed in my home directory to "override" the version installed on the system for my session?

I tried setting an alias which works via command line but not for the script used to generate the configure script.

like image 678
kladd Avatar asked Dec 26 '22 22:12

kladd


2 Answers

Add the path to the binary you want to override to your $PATH environment variable. Like PATH=/path/to/binary:$PATH ./compile

Your added path will then be looked up first when trying to find the compile command. It will only be valid for that execution and will not remain after command has returned. You can use export PATH=/path/to/binary/:$PATH and it will be saved for that session.

EDIT: As Eric.J states, you can use which compile which will output the path to the command, just to make sure it's the right one.

like image 184
Jite Avatar answered Jan 11 '23 17:01

Jite


You can change the PATH environment variable so that your home directory appears before the system directory, e.g.

PATH=$HOME/bin:$PATH

You can then use the which command to ensure the correct binary is being picked up.

like image 24
Eric J. Avatar answered Jan 11 '23 15:01

Eric J.