A case sensitive ~/src folder for Mac Programmers

By default, Macintosh computers the APFS filesystem, which is very unix-like but is not case sensitive. Considering that almost all programming languages are case sensitive, and git is certainly case-sensitive, this can create some problems if you ever have to correct incorrect capitalisation in folders or files.

In other words, let’s say that you have a function “game()” in “game/game.js”. Later on, you realise that this function really should be a class, so you rename the file “Game/Game.js”. The APFS file system won’t regard that as a change, so git won’t see it as a change. Sharing your repository, you’ll find that your code works on your machine but breaks on others, especially those on Linux systems and other filesystems that are case sensitive.

The solution is to move your programming source file folder to a case-sensitive “volume” on the same drive. Here’s how to do it.

First, you’ll want to backup your existing programming folder. Where I usually end up programming is in “~/src” — or “/Volumes/Macintosh HD/Users/<username>/src”. Rename that folder to “src_backup”.

Once you’ve done that, you’ll want to open up your Disk Utility application.

Disk Utility — Create Volume

From there, click on the little plus sign to add a volume. This volume is not a partition — so we won’t be deleting anything, and it will dynamically allocate, so you don’t have to worry about sizing it.

Choose APFS Case Sensitive, and give it a descriptive name, like “sourcecode”. Once you hit Add, it will create a new virtual “volume” which can be accessed like a separate hard drive in the finder.

APFS Case Sensitive

However, you’ll probably still want the convenience of having your source code in your “~/src” folder. This is where the magic comes in — we’re going to create a symbolic link (or symlink) between your “~/src” folder and the new “/Volumes/sourcecode” folder. For all intents and purposes, ~/src is /Volumes/sourcecode, which means that anything in your src directory will now be on a case-sensitive file system.

Go to your favorite terminal program (Terminal.app is the default, though I prefer iTerm2). Assuming your volume is named “sourcecode”, type:

That’s it. Now just copy the files from your “~/src_backup “directory into your new “~/src” directory, and you’re good to go! Happy hacking!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store