Dumping ascii-8bit strings as binary data #138

balinterdi opened this Issue Apr 12, 2013 · 1 comment


None yet

2 participants



I was tracking down why Bundler writes config key-value pairs as binary data and tracked down the problem to be specific to Psych since that's what Bundler uses when available.

I might be missing something, but I don't understand why ascii encoded strings are dumped as binary data:

>> require 'psych'
>> s = "vendor"
>> s.encoding # => <Encoding:ASCII-8BIT>
>> Psych.dump(s) # => "--- !binary |-\n  dmVuZG9y\n"

Is that how it's supposed to work? If so, there's an issue with Bundler because when reading in config values it simply does not work. I'm using MRI 1.9.3-p392 on OSX.

Thank you.

Ruby Programming Language member

"ASCII-8BIT" means that the string encoding is unknown. Since YAML is supposed to be unicode, there is no way for us to know how to convert the string to unicode since the encoding is unknown. Since Psych cannot transcode the string to UTF8, then it saves it as binary.

@tenderlove tenderlove closed this Aug 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment