Call to a member function in() on null when updating locale in Statamic

How to fix this annoying error when you're adding, or updating locales in Statamic 2

Published April 10th 2020

While I was testing Statamic 2's localisation features this weekend, I ran across an issue where I was getting the following error when I tried to add a new locale.

[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function in() on null

A bit more digging showed the issue was in the stash, but on trying to clear it, the same error appeared in the console.

The problem turned out to be that there was already an index.md file that was was keyed for the locale I was trying to re-add.

Removing that file (albeit temporarily) allowed me to refresh the stache and allowed the site to load. Bit annoying, but at least the fix is pretty simple.