# Jruby yaml load issue with floats?

**URL:** <https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865>\
**Category:** Ruby\
**Created:** [February 20, 2009, 1:45pm UTC](https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865 "2009-02-20T13:45:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [February 20, 2009, 1:45pm UTC](https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865/1 "2009-02-20T13:45:44Z")

</div>

Try this with both MRI and Jruby 1.1.6 (with active support 2.2.2)

irb(main):004:0\> require ‘rubygems’  
=\> true  
irb(main):005:0\> require ‘activesupport’  
=\> true  
irb(main):006:0\> YAML.load(YAML.dump(3.0)).eql?(3.0)  
=\> true

MRI returns true, while JRuby returns false !!!

The root cause is that JRuby is loading the yaml as  
irb(main):021:0\> YAML.load(YAML.dump(3.0))  
=\> #\<YAML::PrivateType:0x18ad9a0 @value=“3.0”, @type\_id=“tag:yaml.org,  
2002:float:Float”\>

instead of as 3.0

Has any bug been logged for this? I would have gone ahead and logged  
it, but I am unable to register on codehaus :(. For some wierd reason,  
I just can’t get thru their capta!!! (another bug???).

Would be great if someone could log this one as a bug or point me to  
an already logged bug or otherwise explain this behaviour.

Pradeep

---

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [February 20, 2009, 5:08pm UTC](https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865/2 "2009-02-20T17:08:16Z")

</div>

Pradeep G. wrote:

> The root cause is that JRuby is loading the yaml as  
> irb(main):021:0\> YAML.load(YAML.dump(3.0))  
> =\> #\<YAML::PrivateType:0x18ad9a0 @value=“3.0”, @type\_id=“tag:yaml.org,  
> 2002:float:Float”\>
> 
> instead of as 3.0

This should be fixed on trunk/1.2. Can you test out a nightly build?

[http://jruby.headius.com:8080/hudson/job/jruby-dist/](http://jruby.headius.com:8080/hudson/job/jruby-dist/)

- Charlie

---

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [February 20, 2009, 7:01pm UTC](https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865/3 "2009-02-20T19:01:50Z")

</div>

Charles,

Its still an issue on the 1.2 nightly build.

pradeep@pradeep-laptop:~/jruby-1.2.0/bin$ ./jruby -S irb  
irb(main):001:0\> require ‘rubygems’  
=\> true  
irb(main):002:0\> require ‘activesupport’  
JRuby limited openssl loaded. gem install jruby-openssl for full  
support.  
[http://wiki.jruby.org/wiki/JRuby\_Builtin\_OpenSSL](http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL)  
=\> true  
irb(main):003:0\> YAML.load(YAML.dump(3.0))  
=\> #\<YAML::PrivateType:0x2d80ae @type\_id=“tag:yaml.org,  
2002:float:Float”, @value=“3.0”\>  
irb(main):004:0\> YAML.load(YAML.dump(3.0)).eql?(3.0)  
=\> false  
irb(main):005:0\>

---

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [February 20, 2009, 8:10pm UTC](https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865/4 "2009-02-20T20:10:09Z")

</div>

Pradeep G. wrote:

> Charles,
> 
> Its still an issue on the 1.2 nightly build.

Ahh, so it is. It’s something specific to running with ActiveSupport  
present, because it works fine with normal Ruby.

I’ve filed it here: [http://jira.codehaus.org/browse/JRUBY-3423](http://jira.codehaus.org/browse/JRUBY-3423)

Thank you!

- Charlie

---

<div class="post-metadata">

**Author:** ![pradeepgatram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@pradeepgatram](https://www.ruby-forum.com/u/pradeepgatram)\
**Post date:** [February 21, 2009, 6:07am UTC](https://www.ruby-forum.com/t/jruby-yaml-load-issue-with-floats/160865/5 "2009-02-21T06:07:59Z")

</div>

Thanks Charles 🙂
