# Trouble with Marshal

**URL:** <https://www.ruby-forum.com/t/trouble-with-marshal/73775>\
**Category:** Ruby\
**Created:** [October 26, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/trouble-with-marshal/73775 "2006-10-26T23:16:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 26, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/trouble-with-marshal/73775/1 "2006-10-26T23:16:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 26, 2006, 11:37pm UTC](https://www.ruby-forum.com/t/trouble-with-marshal/73775/2 "2006-10-26T23:37:00Z")

</div>

On 10/26/06, Gavin K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
