Tatsuhiko Miyagawa's Blog

Carton and perl version support: miyagawa/heroku-buildpack-perl

June 17, 2013

Link: Carton and perl version support: miyagawa/heroku-buildpack-perl

Dependencies can be declared using cpanfile and frozen with carton install. The buildpack will install these dependencies using Carton into a cached ./local directory.I implemented the experimental buildpack update to enable Carton and perl versions support.

This enables the use of Carton (dev release on v0.9) to deploy dependencies recorded in carton.lock (you have to check it in to the git repo), and then use the file .perl-version ala plenv to specify the perl runtime version. Only the latest minor point release of all stable releases are supported. See the README for details.

This has been one of my TODOs to make this buildpack actually usable on Heroku, since otherwise a) installation will use the latest cpan modules from CPAN unless you explicitly specify version in cpanfile (which is great) and b) the perl used to run your application is always /usr/bin/perl version 5.10 that comes with whatever OS that runs on Heroku.

I tried to use vulcan to build binaries on Heroku, but it looks a little complicated and requires setting up Heroku addons. I went with the simplest technique to run perl-build on heroku run bash like explained in this article, then scp back the resulting binary to my host.

This makes the perl buildpack runs more like other languages buildpack like Ruby and NodeJS.

Note that I consider this a beta, and you have to specify the git branch #carton in the buildpack URL to use it.

The initial deployment takes a little while to copy vendor perl, then bootstrap all dependencies for carton — which i hope can be eliminated once carton goes 1.0 and support fatpacked executable.

Thanks to @judofyr for his also excellent perloku buildpack that i shamelessly copied the technique to build & download perl binaries.