Diagnosing module installation problems in Heroku

I've been playing with Heroku (a platform as a service) and Mojolicious, which works very well if all of the modules install. Greg Hinkle shows you how to do it. Create your mojo app and deploy it easily to Heroku. As you do, it's dependencies are installed for you.

Pure Perl modules are usually fine, but Heroku is a limited Ubuntu environment that doesn't have all the libraries you probably expect to already be there. One of the modules I needed had DB_File as a deep dependency, so deploying my app (with Heroku toolbelt and Mojolicious::Command::deploy::heroku) fails. I get the rainbow barf from the uni-raptor.

barfing-raptor.png

Being new to Heroku, I didn't know how to diagnose this problem remotely and it took me a couple of hours of reading and experimenting before I ran across the various obvious heroku run which allows me to talk to the my Heroku console.

It's not as simple as running cpanm (once you know where it is) because there's a shebang line problem:

$ heroku run --app appname -- /app/vendor/perl/bin/cpanm --verbose --no-interactive DB_File
Running `/app/vendor/perl/bin/cpanm --verbose --no-interactive DB_File` attached to terminal... up, run.8045
bash: /app/vendor/perl/bin/cpanm: /tmp/perl/perls/perl-5.16.2/bin/perl: bad interpreter: No such file or directory

I can specify the perl path myself to fix that:

$ heroku run --app appname -- /app/vendor/perl/bin/perl /app/vendor/perl/bin/cpanm --verbose --no-interactive DB_File

Now I can watch the output to see that it's missing libdb:

Running `/app/vendor/perl/bin/perl /app/vendor/perl/bin/cpanm --verbose --no-interactive DB_File` attached to terminal... up, run.4646
cpanm (App::cpanminus) 1.5018 on perl 5.016002 built for x86_64-linux
...
--> Working on DB_File
Fetching http://www.cpan.org/authors/id/P/PM/PMQS/DB_File-1.827.tar.gz ... OK
Unpacking DB_File-1.827.tar.gz
...
cc -c  -I/usr/local/BerkeleyDB/include -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"1.827\" -DXS_VERSION=\"1.827\" -fPIC "-I/app/vendor/perl/lib/5.16.2/x86_64-linux/CORE"  -D_NOT_CORE  -DmDB_Prefix_t=size_t -DmDB_Hash_t=u_int32_t   version.c
version.c:30:16: error: db.h: No such file or directory
make: *** [version.o] Error 1
FAIL
! Installing DB_File failed. See /app/.cpanm/build.log for details.

This isn't a huge deal. I can compile DB_File locally and include the result in my app, but now I know that's what I need to do.

Leave a comment

About brian d foy

user-pic I'm the author of Mastering Perl, and the co-author of Learning Perl (6th Edition), Intermediate Perl, Programming Perl (4th Edition) and Effective Perl Programming (2nd Edition).