Cannot install File::HomeDir using cpan on MacOS Mojave for MacTex

I had the exact same problem and found a workaround:

  1. Install the current version of Perl using Homebrew: brew install perl
  2. Check if xcode-select -p points to the Command Line Tools. If not, run xcode-select --switch /Library/Developer/CommandLineTools
  3. Install Mac::SystemDirectory using cpan (not cpanm): cpan Mac::SystemDirectory

I have no experience with Perl and I have no idea why this worked, but it did :)