I'm working on Mac OS X which is shipped with several binaries mostly located in /usr/bin/
and /usr/sbin/
. Since it doesn't have a native package manager like some Linux distros, I got used to managing my own binaries, building and installing in /usr/local/<package_name>/
.
This way, I am able to fully remove a package from my system at the cost of manually update the PATH
and the MANPATH
variables in the .bashrc
file.
Here is a simple example:
Mac OS X ships with ant 1.7.0, located in /usr/bin
. I need to use the latest version, so I download it from Apache and then unzip (build) it to /usr/local/apache-ant-1.8.2
. Then I update my .bashrc
file with:
# Mac OS X original PATH
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
# Apache Ant 1.8.2
PATH="$PATH:/usr/local/apache-ant-1.8.2/bin"
export PATH
I make sure to export the /usr/bin/
and /usr/sbin/
before the ant/bin/
because there are often other binaries besides the ant
that I don't want to override.
The problem is that when I type which ant
I get /usr/bin/
. So I rename the /usr/bin/ant
to /usr/bin/ant-old
in order to work with the latest build.
While this works, I want to know if there are better approaches to replacing a system binary (mainly to avoid the last rename).