Delan Azabani

make error 253 when installing any Ruby gems on Windows

 265 words 1 min  attic jekyll

Recently I've been unable to install any gems that require native extensions. This included both rdiscount and wdm, the latter of which I need to run jekyll serve -w and automatically rebuild sites as needed on Windows. The cause of the problem turned out to make no sense.

Active code page: 65001
generating rdiscount-x64-mingw32.def
make: *** [rdiscount-x64-mingw32.def] Error 253

Perhaps it was the code page? To force the use of UTF-8 everywhere, mainly so that Liquid doesn't break on Unicode characters when running Jekyll, I had set up cmd.exe to chcp 65001 whenever opened by creating the registry key:

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun REG_EXPAND_SZ

Disabled that, tried again, no change, so I put it back. Stuck for an hour or two, I came back and tried running make manually on the gem directory, and lo and behold, a window exclaimed that sh.exe has stopped working.

Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	sh.exe
  Fault Module Name:	KERNELBASE.dll
  Exception Code:	c00000fd

Confirming this, running the DevKit's sh crashes, while bash does not. I then took the opportunity to upgrade from Ruby 1.9.3 to 2.0.0, but sadly nothing changed still.

After some further investigation, it turns out that sh has a stack overflow when being run through ansicon, a wrapper that processes ANSI escape sequences output from a Win32 console. I had Console2 configured to run cmd.exe through it, so that all programs were essentially wrapped, and any sequences output by them would work as expected.

Simple solution: when running gem, open cmd.exe directly. It's not like gem has coloured output or anything, so you're not missing out.