Compile and install git-crypt on OS X

A guide for macports users
Published on January 29, 2016 in How-tos — 1 min read
Tags:

Git-crypt is a nice piece of software, it’s great to keep sensible data secure in a repository.

Unfortunately the official installation guide only supports Linux and Homebrew users. So what if you’re a happy Macports user like me?

Install the requirements

First step, you need to have Xcode and macports installed. Run gcc --version and g++ version to be sure you can compile the software.

Check GCC and G++

Now install openssl and git (it is very likely you have them already installed). Actually git is not needed at compile time but at runtime.

$ sudo port install openssl git

Let’s get the source

$ git clone git@github.com:AGWA/git-crypt.git
$ cd git-crypt

Compile errors

If we compiled it now, make would fail and you would get fatal error: 'openssl/aes.h' file not found.

make fails to compile git-crypt

What’s up? It turns macports libs are not seen by GCC and G++ by default.

Fix!

To fix it, we have to edit bash_profile file

$ nano ~/.bash_profile

and add the lines below:

export C_INCLUDE_PATH=/opt/local/include/
export CPLUS_INCLUDE_PATH=/opt/local/include/

What have we done? We’ve just told GCC and G++ to look for headers also in Macports path.

Reload .bash_profile to apply the edits…

$ source ~/.bash_profile

…and check the variables to be set.

$ env | grep C_INCLUDE_PATH
$ env | grep CPLUS_INCLUDE_PATH

Now let’s try again to compile

$ make

It should be run smoothly.

So it’s time to install git-crypt. For best practice, it’s better to install it in /usr/local. To do so run:

$ sudo make install PREFIX=/usr/local

Happy encryption!


Thanks for reading.


Related links

http://www.network-theory.co.uk/docs/gccintro/gccintro_23.html



Comments

Got some words you want to share? Tell me!