Day 7. Cat In A Box on a Stick

Today's recipe is a quick one to describe how to get yourself a portable Perl for Windows that runs all the Catalyst goodies that you want for your application.

While there is a Perl::Dist::CatInABox I can't recommend it just yet, as some of the modules that Catalyst requires don't install cleanly under Windows. On the other hand these failures are generally not going to stop a typical Catalyst installation from working, although watch out for Windows' eccentricities like signal handling in your app. Also, note that BerkelyDB takes some deep voodoo that's beyond me to work in Strawberry Perl (as well as administrator access to install Sun's msi installer), so avoid modules with these dependencies too if you want them to work with Strawberry at this stage.

Step one, find a Windows machine.

Some time really soon, this is going to be a lot easier than it is now. For the mean time, I've been doing all this work on a Mac with a copy of Windows XP working under Virtual Box. You may not need Administrator access for these steps to work, but you do need to do the initial installation of CPAN modules in a path without spaces in it.

Step two. Grab portable Strawberry Perl

Here is the Strawberry Perl website. Go there and grab the latest portable strawberry Perl. Unzip it into c:\strawberry, or any other path without spaces.

Step three, Introduce yourself to the joy of MSDOS batch file programming

This little script should appear in the portable Perl distribution in due course, but for now, this will run a Windows shell with all the environment variables set for Perl to work. Save it as startperl.bat in c:\strawberry\.

 set bindir=%~dp0
 set perlpath="%bindir%\perl\bin"
 set buildpath="%bindir%\c\bin"
 set PATH=%PATH%;%perlpath%;%buildpath%
 start cmd

Step 4, set up CPAN.

Actually there's not much to this. Portable Strawberry Perl already has a sensible CPAN mirror set up, but given that Catalyst requires quite a lot of dependencies, you might want to set up CPAN::Mini.

Step 5, Introduce yourself to the joy of windows command line editing.

Some of the tests for Catalyst's dependencies don't work under Windows at the moment. From memory, the worst offender is HTTP::Server::Simple which hangs, due to Windows doing signal handling different to everybody else. Until this module's signal handling is redone to use POE's signal handling under windows, the only sane thing for this module to do is to skip the offending test on Windows. There's a patch waiting to be applied in the RT Queue.

Anyway, while you could notest install HTTP::Server::Simple and then go into your application's root directory and then the perl Makefile.PL \n make installdeps process (remember windows shell doesn't have && ), I've found this a little unpredictable (probably because of my unfamiliarity with Windows), so here's a one-liner that skips testing for everything:

 perl -MCPAN -e "CPAN::Shell->notest(install => q{.})"

Step 6, run your server

My preference is to put my application's directory in the same directory that I placed the startperl.bat script (see above).

Now we can run the following script to start the test server (the first lines are just the same as before):

 set bindir=%~dp0
 set perlpath="%bindir%\perl\bin"
 set buildpath="%bindir%\c\bin"
 set PATH=%PATH%;%perlpath%;%buildpath%

 echo Starting myapp  server please be patient
 perl "%bindir%\MyApp\myapp_server.pl

And you're good to go. Copy C:\strawberry to wherever you like. If you want to install extra CPAN modules, remember to move it back into a path without spaces before proceeding. Welcome to Catalyst development on Windows without (too much) pain.

ACKNOWLEDGEMENTS

Thanks to Adam Kennedy and the rest of the contributors to Perl::Dist, and to the participants in the vertical metre of beer contest. And thanks to Microsoft for realising that they have to make an effort not to be second class citizens.

AUTHOR

Kieren Diment <zarquon@cpan.org>