Trouble with Marshal

I’m trying to use Marshal on Windows to cache some results that take a
while to generate, and I’m getting some bad results.

Using the following simple code…
all = RANGE.map{ |i| p4 describe -s #{i} }
File.open( ‘desc.marshal’, ‘w+’ ){ |f| f << Marshal.dump(all) }
all = Marshal.load( IO.read( ‘desc.marshal’ ) )
…I can get different results depending on which range of changelists I
ask for.

Sometimes it’s:
in `load’: marshal data too short (ArgumentError)

Sometimes it’s:
in `load’: undefined class/module
/SpecToolClient/SpecToolClient/ApplicationData/Catalog_525_600-670/Optio
ns/Exterior_WindshieldRetainer/ (ArgumentError)

And sometimes it’s:
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application’s support team for more information.

I’m trying to pare it down to a simple test case. (Right now it’s a 4MB
Marshal file.) As I do that, however…is there something obvious that
I’m doing wrong in the above code?

On 10/26/06, Gavin K. [email protected] wrote:

I’m trying to pare it down to a simple test case. (Right now it’s a 4MB
Marshal file.) As I do that, however…is there something obvious that
I’m doing wrong in the above code?

Wild guess, but can you try opening the file with “wb+”? The marshal
format
is binary, isn’t it, so the windows line ending could make a difference.

/Nick

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs