Wednesday, February 4, 2009

Ruby on Windows

Ugh.

File.new

Spent about three hours tracking down weirdness with the Ruby File class on Windows. My unit tests create several files, as does some of the code I'm working on. All the tests work fine on my Mac, and the tests all clean up after themselves just fine. Deploy it all to Windows, and all of a sudden tests are failing and there are a ton of test files/folders leftover. Couldn't leave well enough alone.

Turns out that File.new on Windows leaves a handle open. Maybe it does on the Mac, too. Didn't dig in. All I know is that on Windows I had to explicitly call close() on each file to ensure that there weren't any handles laying around, but the Mac worked fine without it. This is, incidentally, different from Java. In Java a File object instance is so abstract that the file just has to exist.

Tempfile

Great library. Did everything I needed...until I discovered, like some other poor schlebs, that Tempfile operates in ASCII mode exclusively. All my writes were getting jumbled up and truncated. After playing around with FileTemp, I ended up abandoning the use of a temporary file altogether, not having found a very good solution, and not having time or the inclination to try my hand at fixing it.

No comments: