Psych isn’t Syck

Ruby 1.9.2 introduced a new YAML parser called psych, which in theory is better than syck, the existing parser.  Syck is the parser in 1.8.7 and REE and still the default in 1.9.2 but it is unmaintained.  Ideally, we’d be able to just switch over to psych with 1.9.2, but there are number of outstanding issues with psych: it doesn’t work with delayed job and it also breaks merge keys.  Since psych isn’t quite ready for prime time, 1.9.2 defaults to syck unless libyaml is installed, in which case it will be compiled to use psych.  The result is a confusion of rubies: you need to check the value of YAML::ENGINE to determine which parser your ruby has compiled-in — hardly a satisfying state of affairs. Worse yet, some very useful gems don’t work with syck, for instance VCR.

Until the syck vs psych confusion gets sorted out, Tddium supports two versions of ruby 1.9.2: the default with the syck YAML parser and an alternate with psych.  To use the psych-enabled ruby 1.9.2 you can add the following to your config/tddium.yml and run tddium suite –edit to update the suite configuration:

[sourcecode lang=”ruby”]
# config/tddium.yml

:tddium:
:ruby_version: ‘ruby-1.9.2-p290-psych’

[/sourcecode]

And voila! your tests will run with a ruby that has psych compiled in.

2 Comments

  • Myron Marston (@myronmarston) December 17, 2011 at 2:20 am

    > Worse yet, some very useful gems don’t work with syck, for instance VCR.

    This isn’t really true. Versions prior to 1.7.0 just required ‘yaml’ and used whatever the default was. Starting in 1.7.0, VCR attempted to load psych, and fell back to syck when psych could not be loaded. Unfortunately, the YAML emitted by these two are not always compatible, so if your cassettes were recorded using one the tests may not work when run against the other.

    VCR 2.0 supports any serializer. It provides :yaml, :syck, :psych and :json serializers, or you can provide your own.

    • jaymoorthi May 8, 2012 at 9:23 pm

      Great to hear that more recent versions of VCR are robust to YAMLer differences. We use VCR every day as we’re building Tddium.

Post a Comment