DEV Community


How To Avoid Filename Case Errors in Production

ambroselittle profile image Ambrose Little ・2 min read

If you are working on Mac (or, I imagine, Windows), you will most likely be working on a case insensitive file system. This is great for a lot of reasons, but not great for one, namely if your production system is using case sensitive file system, which is very likely.

More than once at different companies in my career, I have had this issue bite me/my team. I will acknowledge up front that one way (probably even the best way) to solve this is to have a CI build that runs tests on an environment that more closely matches production. I mean, ideally we should do that anyway for a number of reasons, but still, 1) you may want to know you broke something before committing and 2) you may want not have that set up even if it is ideal.

So here is a relatively painless way to solve that.

First, close any apps that may be referencing your code. Then:

  1. Create a new Volume in Disk Utility, choose APFS (Case-sensitive, Encrypted) as the format. You do not have to encrypt, but why not, this is your IP after all. Let's call the volume Dev and give it enough space for all your code and then some.

  2. Let's say your code folder is named Repos. So in iTerm2 (you are using iTerm2, right??), go to where that folder is and type: mv Repos /Volumes/Dev/ to move the folder to your new volume. Now go make some coffee, watch a movie, etc. Mine took about 7-8 min for around 14GB.

  3. In the same folder (where your actual Repos folder used to be), type ln -s /Volumes/Dev/Repos Repos. I assume you know what this does, but just in case you do not, it will make a symbolic link to where you just moved all those files. This means (in theory at least) you should not have to change anything else.

Now you can open your coding apps and continue. I cannot guarantee there will not be side effects from this, but I can say that it will help you to avoid casing issues going forward. If you have tests, run them and see. Of course, this only solves for each dev individually on a team, so the better solution will continue to be a CI and/or test or even staging environment to be sure, but I think it can still be helpful. YMMV!

Discussion (0)

Editor guide