Today I learned…

If the Path value in either of these registry entries

HKCU\Environment
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

is declared REG_SZ instead of REG_EXPAND_SZ, and contains %-delimited references to environment variables, then the final generated Path environment variable will contain unexpanded environment variable references.

This will cause the GnuWin32 Bison port to generate calls to _spawnvp() that tickle a bug in the Microsoft C runtime, and lead to the unhelpful error:

m4: invalid argument

The solution? Easy peasy:

  1. Set both Path entries to REG_EXPAND_SZ. This won’t actually help, but it’s tidy.
  2. Remove all environment variable references from your path.
  3. Restart your computer, because Windows caches things & isn’t too good at noticing when its cache is no longer valid.
  4. Hope for the best.