ruby-on-railsrubyutf-8dragonfly-gem

"DRAGONFLY: couldn't marshal decode string - got incompatible marshal file format (can't be read)"


In Rails 3.2.22, Ruby 2.2.2, I'm getting log writing failed. "\xCB" from ASCII-8BIT to UTF-8 (and a similar error with "\xD9") as the only output in the Rails log when I make a request. Literally, here's the development log when starting up and making one request to the server:

>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3001, CTRL+C to stop
log writing failed. "\xCB" from ASCII-8BIT to UTF-8
log writing failed. "\xD9" from ASCII-8BIT to UTF-8
log writing failed. "\xD9" from ASCII-8BIT to UTF-8

The return is always just a bare "Not found."

This came up after an update to the Dragonfly gem (which brought along a minor Fog update), but I don't see how that could be causing this unless the config file is seriously botched. Rspec tests run, but Cucumber features which use Capybara to request pages from the server fail (because they're just getting "Not found.")

This is similar to "rake test and error : log writing failed. "\xE2" from ASCII-8BIT to UTF-8", but the accepted answer to that question is just, "figure out what's generating the UTF-8 string and fix its encoding," and I have no good leads for figuring out what's generating the string.

ETA: The Dragonfly update is indeed the issue. I walked back the update and then went through their update guide step-by-step, and while I'm still getting the same responses from the server, Dragonfly is now logging to the Rails logger, and I'm getting

DRAGONFLY: couldn't json decode string - got 795: unexpected token at 'i٢'

So Dragonfly is the culprit at some level.

ETA2: Following a similar issue in Dragonfly's Github repo, I added allow_legacy_urls true to my Dragonfly configuration, and now the error is this:

DRAGONFLY: couldn't marshal decode string - got incompatible marshal file format (can't be read)
format version 4.8 required; 105.217 given

...which is almost exactly the same error found in "Ruby on Rails - incompatible marshal file format" (the "given" Marshal version is different), but the solutions there aren't helping me.


Solution

  • In the end it seems likely that the problem was some kind of unflushed cache. I put the branch aside for a few days to work on other issues, during which time I stopped and restarted the development server several times on other branches. When I returned to this branch, I rolled back to before the Dragonfly upgrade, then ran all the other gem updates I wanted to do and did the Dragonfly upgrade last, following the upgrade instructions. This time I had no issues.

    So my best guess is that there were cached items (or a cache map) left over from an incomplete upgrade which were essentially invalidating the cache, causing the reported errors.