Like most people, I pull my site down to develop locally. After all, it’s safer. But also like most people, my live machine is a linux box and my personal machine is not. In fact, it’s a Mac, running whatever the latest OS X is. But don’t worry, today’s drama happens on Windows as well.
You see, I downloaded my local data, imported my database, changed my URLs to local, and stared at a page that had the wrong data. Or rather, the right data and the wrong image. The page for “Sam” was showing me a photo for another character named “Sam.” But on my live site it was fine.
Commence the Debugging Commence the Debugging
The first thing I did was copy the image to a new folder to try and re-upload it. Only that didn’t work out the way I thought it would. You see, I knew the filename was
Sam.jpg so I tried to copy that over:
cp ~/sites/example.com/wp-content/uploads/2018/05/Sam.jpg ~/Downloads
Only when I went to look, it was again the bad image. In fact, when I looked at all the files in the folder, there was only one file named ‘sam’ when there should be two
Things were starting to become clear. Next I copied it and renamed it
sam.jpg and got an error:
I’ve got it now. Mac doesn’t understand the different between upper and lower case. It’s not case sensitive.
Bad News: No Easy Fix Bad News: No Easy Fix
I’m really sorry about this. There isn’t an easy fix.
First of all, if you wanted to fix your main hard drive, you would have to reformat it. That’s a pain in the ass. Second? Your Mac will not be happy and things will break. For example, the Steam app doesn’t like it if your Mac is case sensitive. Seriously, I have no idea why. But it’s what it expects.
This means the ‘fix’ is to partition your hard drive. Since I’m using AFPS, I opted to make a volume instead of a partition, which feels pretty much the same but it’s not. I opted for AFPS with case sensitive and encrypted because I’m generally a neurotic. Making a volume is very fast, and once I was done, I copied everything in my
~/Sites/ folder over to
websites is the name of my new volume).
And now it looks great!
Except… I still only see one in terminal. I freaked out for a moment and then I realized that while the GUI is smart enough to know that Sam and sam are both S’s, terminal put the capital letters above the lowercase. So all the S’s came before all the s’s.
The last step was to move my copy of Chassis over to the new websites volume, spin it back up, and finally it was working properly.
The Moral? The Moral?
Don’t use case-sensitive filenames. Or filenames with special characters like á or í because operating systems are stupid.
No seriously, that’s it. Haven’t you wondered why people advocate we all use all lower-case for filenames in our code repositories? Because different operating systems are stupid. They don’t always talk properly to each other, they have different ideas of right and wrong, and they’re never going to agree. If you work with multiple operating systems, aim at the lowest common denominator, pick a style, and stick the hell to it.
That’s your moral.