The shorter path to deployment heaven

Now that there is cpanminus, I've modified the handy little module CPAN::AutoINC to prefer cpanminus over CPAN.

So now when users download and run my programs/scripts for the first time, instead of failing with the dreaded message:

Can't locate Foo/ in @INC (@INC contains: [a dozen or more of paths....]).
BEGIN failed--compilation aborted at /some/path line 123

which users or even Perl novices have no clue on how to fix, the program will instead automatically download every necessary CPAN modules into the user's home directory and runs out-of-the-box on the first try!

$ download-bca
Building File-HomeDir-0.89 for File::HomeDir...                                    
File::HomeDir installed successfully.                                              
Building File-Slurp-9999.13 for File::Slurp...                                        
File::Slurp installed successfully.                                                   
==> Found dependencies: Pod::Coverage, DateTime, Test::Pod::Coverage, Log::Any, Any::Moose, Mouse
==> Found dependencies: Devel::Symdump                                                           
Building Devel-Symdump-2.08 for Devel::Symdump...                                                
Devel::Symdump installed successfully.                                                           
Building Pod-Coverage-0.20 for Pod::Coverage...                                                  
Pod::Coverage installed successfully.                                                            
Building App-Options-1.07 for App::Options...
App::Options installed successfully.
(the program finally runs)

As the developer, you only need to put "use CPAN::AutoINC" at the top of your main script. How's that for deployment heaven? Zero installation, zero configuration (thanks to cpanminus), zero dependency outside of Perl core modules.

But there's a catch. The user (or the user's sysadmin) still needs to install CPAN::AutoINC and needs to install and bootstrap local::lib first. So it's not really an out-of-the-box experience yet.

miyagawa++ is already planning to automatically bootstrap local::lib from cpanminus, and the logic behind CPAN::AutoINC is just a couple of dozen lines that can be embedded easily into the script (this process can be made automatic with distribution building tools like Dist::Zilla plugin).

Since cpanminus has zero dependencies, we can simply include it too in our application.

And maybe in the future there can be GUI interfaces for cpanm, so it can display a nice dialog to ask confirmation via the desktop.

Be prepared to be able to provide a much nicer experience for your users.

Leave a comment

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays).