From: Mauricio Fernandez Date: 2006-02-02T08:48:17+09:00 Subject: Re: memoize to a file On Thu, Feb 02, 2006 at 06:49:49AM +0900, Daniel Berger wrote: > > and it instead of silently failing I now see the error message: "in `load': > > marshal data too short (ArgumentError)" > > > > My questions: > > 1 What is causing this error? (possibly Windows related?) > > That is odd. I've run it on Windows with no trouble in the past. (FTR: file not opened in binary mode, [177651]) > Is it possible you ran this program using 1.8.2, downloaded 1.8.4, then > re-ran the same code using the same cache? It would fail with that > error if such is the case, since Marshal is not compatible between > versions of Ruby - not even minor versions. The Marshal format hasn't changed for a while: batsman@tux-chan:~/Anime$ ruby182 -v -e 'p [Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION]' ruby 1.8.2 (2004-12-25) [i686-linux] [4, 8] batsman@tux-chan:~/Anime$ ruby -v -e 'p [Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION]' ruby 1.8.4 (2005-12-24) [i686-linux] [4, 8] Also note that ruby can read Marshal data in older formats if the MAJOR_VERSION hasn't changed (i.e. if only the MINOR_VERSION was increased): if (major != MARSHAL_MAJOR || minor > MARSHAL_MINOR) { rb_raise(rb_eTypeError, "incompatible marshal file format (can't be read)\n\ \tformat version %d.%d required; %d.%d given", MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); } if (RTEST(ruby_verbose) && minor != MARSHAL_MINOR) { rb_warn("incompatible marshal file format (can be read)\n\ \tformat version %d.%d required; %d.%d given", MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); } (after some searching...) Back in Apr. 2001, matz said that "Marshal should not change too much (unless in upper compatible way)" [14063]. The last minor change happened after 1.6.8 (6 -> 8), and MARSHAL_MAJOR was already 4 in v1_0_1, 7 years, 2 months ago (at which point I got tired of CVSweb). Marshal's format is more stable than we think. -- Mauricio Fernandez