Dist::Zilla β™₯ encoding

Reading time: 4 minutes

Last weekend I went to a Dist::Zilla “micro-hackathon” at Ricardo Signes' house. This is something we’ve done before, setting aside some focused time to tackle something tough. This time, we set out to fix the leaky encoding handling in Dist::Zilla and Ricardo explains the result well in his blog.

But what about Plugins? πŸ”—︎

I’m really happy that we finally fixed Dist::Zilla’s handling of encoding, but unfortunately, Dist::Zilla is only as good as the ecosystem of plugins for it on CPAN. OK, really, it’s good on its own but it’s even better because of its ecosystem.

As Rik said, lots of things will just work better than before, particularly if you stick to UTF-8 for your files. The plugins most directly affected are FileGatherers and FileInjectors β€” anything that calls add_file β€” in particular anything that reads a file off disk without a particular encoding and then uses that as the content of a Dist::Zilla::File::* object.

For example, if you wrote a plugin that reads a template file, runs it through some other libraries, and stuffs the result into the content of a File object, then you really ought to sit down and think about whether you ought to be reading :raw or with some decoding layer. (You should probably shouldn’t read with the default layers, which might do CRLF translation on Windows.) Whatever you decide, I recommend Path::Tiny and methods it offers like slurp_raw and slurp_utf8.

FileMungers are probably fine. Typically, they read content β€” which is now decoded text β€” then do something with it, and then stuff it back into content. Munging is text in and text out, and Dist::Zilla will take care of encoding it before writing it to disk.

Come out, come out, wherever you are… πŸ”—︎

Using grep.cpan.me, I tried to review all the FileInjectors and FileGatherers I could. Most of them look like they’ll be unaffected by the changes in Dist::Zilla. But some looked suspicious and I’ll give a list of them below.

If you wrote one of these, please review it for any changes you need to make for Dist::Zilla version 5 and release a -TRIAL version to CPAN. Follow the instructions at the bottom of Rik’s post to get the -TRIAL version of Dist::Zilla and its dependencies.

If you use any of these, try them out with Dist::Zilla version 5 and see if it breaks anything for you. If so, let the author know right away.

To be clear, I’m not sure these need work, but they’re doing things that concern me.

If you wrote or use a FileGatherer or FileInjector that is not on the list, that doesn’t necessarily mean you’re safe. It just means that a quick skim of your code didn’t throw up any red flags.

Micro-hackathon for the win πŸ”—︎

If you’ve got some project that you’re stuck on, I encourage you to grab a friend, set aside a day or two, and see if a micro-hackathon like ours can get you unstuck.

In addition to getting Dist::Zilla fixed, I had a lot of fun. Whenever I get to sit down and work with Rik, I learn something new. This time, I feel like a lot of work I’ve been doing around encoding in the last year all came together in my head and made sense.

Beyond that, I picked up a few editor, Moose and Mac tricks; got to visit most of Rik’s favorite Bethlehem dives; tried saffron-almond ice cream; and learned several new board and card games. Woo hoo!

Thank you to Rik (and his family) for a great weekend!

β€’      β€’      β€’

If you enjoyed this or have feedback, please let me know by or