# Ruby Marshaling

**URL:** <https://www.ruby-forum.com/t/ruby-marshaling/228028>\
**Category:** Ruby\
**Created:** [April 6, 2013, 9:48pm UTC](https://www.ruby-forum.com/t/ruby-marshaling/228028 "2013-04-06T21:48:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![my-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@my-ruby](https://www.ruby-forum.com/u/my-ruby)\
**Post date:** [April 6, 2013, 9:48pm UTC](https://www.ruby-forum.com/t/ruby-marshaling/228028/1 "2013-04-06T21:48:22Z")

</div>

From the doc: [Module: Marshal (Ruby 2.0.0)](http://www.ruby-doc.org/core-2.0/Marshal.html)

(a) In normal use, marshaling can only load data written with the same  
major version number and an equal or lower minor version number.

(b) If Ruby’s “verbose” flag is set (normally using -d, -v, -w, or  
–verbose) the major and minor numbers must match exactly.

Can anyone give me simple examples for the above two points ?

Thanks

---

<div class="post-metadata">

**Author:** ![my-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@my-ruby](https://www.ruby-forum.com/u/my-ruby)\
**Post date:** [April 6, 2013, 10:06pm UTC](https://www.ruby-forum.com/t/ruby-marshaling/228028/2 "2013-04-06T22:06:06Z")

</div>

What didn’t you understand, and what are you trying to ask? What are  
you looking for in examples? What specifics are you focusing on?

The documentation is clear enough about the versioning rules, with  
their example, provided you understand enough fundamentals.

> > str = Marshal.dump(“foo”)  
> > =\> “\x04\bI"\bfoo\x06:\x06ET”  
> > [str[0].ord, str[1].ord].join(“.”)  
> > =\> “4.8”  
> > str[1] = “\x07”  
> > =\> “\a”  
> > Marshal.load(str)  
> > =\> “foo”  
> > str[1] = “\x09”  
> > =\> “\t”  
> > Marshal.load(str)  
> > TypeError: incompatible marshal file format (can’t be read)  
> > format version 4.8 required; 4.9 given  
> > from (irb):28:in `load' from (irb):28 from /home/adam/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in `’

---

<div class="post-metadata">

**Author:** ![my-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@my-ruby](https://www.ruby-forum.com/u/my-ruby)\
**Post date:** [April 7, 2013, 6:28am UTC](https://www.ruby-forum.com/t/ruby-marshaling/228028/3 "2013-04-07T06:28:19Z")

</div>

Love U Ruby wrote in post #1104755:

> From the doc: [http://www.ruby-doc.org/core-2.0/Marshal.html](http://www.ruby-doc.org/core-2.0/Marshal.html)
> 
> (a) In normal use, marshaling can only load data written with the same  
> major version number and an equal or lower minor version number.

- By `normal` use what they tried to classify? And one example to see  
**can only load data written with the same major version number and an  
equal or lower minor version number.**

> (b) If Ruby’s “verbose” flag is set (normally using -d, -v, -w, or  
> –verbose) the major and minor numbers must match exactly.

- One example where major and minor number is equal.

---

<div class="post-metadata">

**Author:** ![my-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@my-ruby](https://www.ruby-forum.com/u/my-ruby)\
**Post date:** [April 7, 2013, 9:08am UTC](https://www.ruby-forum.com/t/ruby-marshaling/228028/4 "2013-04-07T09:08:41Z")

</div>

What is the purpose of the comments regarding the interpreter. I think  
they  
may be misleading because if there’s one prominent thing -v prints is  
the  
version of Ruby!

What matters is Marshal::MAJOR\_VERSION, and Marshal::MINOR\_VERSION, and  
they have been 4 and 8 for some time. They are still 4 and 8 in Ruby 2.
