Where should I install new (source code) software on a Mac?
I am new to the Mac philosophy, but I have been using Ubuntu since a while. Now I am using Mac at work, and I have to install a few programs, not apps, from source code distribution.
I did try to gunzip
a folder in /usr/local/
but it says permission denied
. Same result with sudo
. The su
command just freezes.
Is /Users/
a better place to go? I suppose I do not need permission to write in there, right?
Where should I install new software (from source code distribution) on a Mac?
To start we should define a few terms. An install from source code means that the software needs to be built before it can be executed.
So your first step is to find a place on your computer to perform the build. The best place for this is a directory in your home directory. I use a directory at ~/src/
to hold the packages. So, create this folder and unpack your source into here. Then you can build the software here.
When it comes to the executable files man hier
will tell you that /usr/local
is the place to install things not included in the OS. Homebrew, for example, will install into here. So executables should go into /usr/local/bin
. Most software packages will have an install tool that will perform this step. Of course /usr/local/bin
needs to be in your PATH variable.
This is identical to Ubuntu in almost every respect.
I did try to gunzip a folder in
/usr/local/
but it says permission denied.
/usr/local/
is a protected directory in macOS. The observed behaviour in your case is due to System Integrity Protection. SIP does not allow even the root user or using sudo to chown
/usr/local/
.
As per man hier
, /usr/local/
is the recommended directory for placing executables, libraries, etc. not included by the basic operating system. So it is where you should be installing your software (from source). The approach to take here is to create a directory under /usr/local
and chown
it to logged in user. This new directory can be used to install new software as per your liking.
/Users/
houses the users home directories, along with a Shared directory, shared between users. So, this is not the place to install new software, whether from source or not.
You can also refer to this nicely written answer discussing Standard for macOS filesystem.