Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syck seems to not work on ruby 2.2.0p0 (2014-12-25 revision 49005) [i686-linux] #9

Closed
ghost opened this issue Dec 25, 2014 · 14 comments · Fixed by #12
Closed

syck seems to not work on ruby 2.2.0p0 (2014-12-25 revision 49005) [i686-linux] #9

ghost opened this issue Dec 25, 2014 · 14 comments · Fixed by #12

Comments

@ghost
Copy link

ghost commented Dec 25, 2014

Hello,

This is an error possibly on ruby 2.2.0p0.
syck works perfectly fine on ruby 2.1.5 for me.

The error I get is when I try to do this here:

YAML::ENGINE.yamler

I used this before to set syck.

When I do this, though, I immediately get this error:

NameError: uninitialized constant Psych::Syck::ENGINE

Both psych and syck were required before I tried the above.

I assume something has changed in between these two ruby
versions but I am not quite sure how to trace back this error.

Thanks.

@paneq
Copy link

paneq commented Dec 26, 2014

+1.

I was wondering whether YAML = Syck is the new way to use Syck instead of Psych globally?

@nicolai86
Copy link

+1.

Any ideas on how to work around this issue for now, without downgrading your ruby?

@fredv
Copy link

fredv commented Apr 25, 2015

Hi Aaron @tenderlove,
this seems to be because of the removal of YAML::ENGINE in psych. (see https://github.com/tenderlove/psych/blob/24ff7855ca2f62e59fc951fa30b225f42369c2a2/CHANGELOG.rdoc, Sun May 25 11:35:41 2014 Zachary Scott e@zzak.io * test/psych/*: YAML::ENGINE was removed in [Bug #8344])

Is there an alternative way? Maybe the constant overwriting part could be optional or another version switch included?

This should be a legacy problem, for our case it's about handling different parsing behavior of psych and syck (I think I remember some cases where syck can parse fairly valid structures from technically invalid YAML ... which is awkward on its own I guess).

We will work around this by not using syck in this case as fallback, I think.

Thank you for putting together both libraries!

@jcabasc
Copy link

jcabasc commented May 13, 2015

Is there any update on this? Still having the same with ruby-2.2.0 or greater.

@hsbt
Copy link
Member

hsbt commented May 13, 2015

Hi, If you submit a patch of this issue, I will merge it.

@dbackeus
Copy link

+1

@ccutrer
Copy link

ccutrer commented Jun 9, 2015

You should be able to check YAML.name. In regular ruby 2.2, you get "Psych", but with the syck gem you get "Syck".

@illtellyoulater
Copy link

So, is it still possible to use the "syck" engine with Ruby 2.2?

In some old source code I had this:

YAML::ENGINE.yamler='syck'  # using old version of engine will avoid dumping to binary format 

But now I can't quite understand what I meant myself? :)

Given that it seems I can't use "syck" anymore with Ruby 2.2, can I just remove YAML::ENGINE.yamler='syck' and it will still be able to parse the old "syck" serialized data?

@GCinellu
Copy link

+1

@courtenay
Copy link

this appears to be broken again on 2.3.x

irb
irb(main):001:0> RUBY_VERSION
=> "2.3.4"
irb(main):002:0> require 'yaml'
=> true
irb(main):003:0> require 'syck'
=> true
irb(main):004:0> YAML::ENGINE
NameError: uninitialized constant Syck::ENGINE
	from (irb):4
	from /Users/courtenay/.rbenv/versions/2.3.4/bin/irb:11:in `<main>'

looking at the code for engine_manager should be possible to just require that, but..

irb(main):006:0> require 'yaml/engine_manager'
/Users/courtenay/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/syck-1.2.0/lib/yaml/engine_manager.rb:70: warning: already initialized constant Syck::ENGINE
/Users/courtenay/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/syck-1.2.0/lib/yaml/engine_manager.rb:49: warning: previous definition of ENGINE was here
=> true
irb(main):007:0> YAML::ENGINE
=> #<Syck::EngineManager:0x007fb4d993cc78 @yamler=nil>
irb(main):008:0> YAML::ENGINE.yamler
=> nil
irb(main):009:0> YAML::ENGINE.yamler = 'syck'
NameError: constant Syck::Object::YAML not defined
	from /Users/courtenay/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/syck-1.2.0/lib/yaml/engine_manager.rb:34:in `remove_const'
	from /Users/courtenay/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/syck-1.2.0/lib/yaml/engine_manager.rb:34:in `yamler='
	from /Users/courtenay/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/syck-1.2.0/lib/yaml/engine_manager.rb:33:in `class_eval'
	from /Users/courtenay/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/syck-1.2.0/lib/yaml/engine_manager.rb:33:in `yamler='
	from (irb):9
	from /Users/courtenay/.rbenv/versions/2.3.4/bin/irb:11:in `<main>'

it appears that this fixes it somewhat in engine_manager

-      Object.class_eval <<-eorb, __FILE__, __LINE__ + 1
+     ::Object.class_eval <<-eorb, __FILE__, __LINE__ + 1

i'm not sure if this is right though :)

@mikhailov
Copy link

is there a plan to get it working with Ruby 2.3.5?

@nuritnt
Copy link

nuritnt commented Oct 9, 2019

any news on this?

@hsbt
Copy link
Member

hsbt commented Oct 10, 2019

Nothing. I always welcome your patch.

@intrip
Copy link

intrip commented Aug 8, 2023

is there a plan to get it working with Ruby 2.3.5?

It works with Ruby 2.3.5, when you require "syck" the YAML parser is automatically replaced by syck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.