Vanilla/Strawberry Perl on a Stick

Alias on 2008-02-21T15:34:38

With XML::Parser solved, the next biggest emerging Want To Have for people is clearly showing itself to be relocation.

My primary use case for this feature is colloquially known as "Perl on a Stick", or some form of .zip file release that you can expand onto a flash drive, and then carry a Perl installation in your pocket (with CPAN install support, and potentially a minicpan cache as well)

Since the Win32 binary seems to handle relocation OK, that just leaves various hard-coded paths in config modules, primarily Config.pm, Config_heavy.pl and Config/CPAN.pm.

Most suggested solutions for this problem seem to focus on rewriting paths in files from an old path to a new path.

I see this as being fairly naive.

For one, who's to say exactly WHAT you are going from and to. And when will you run this conversion script? In the general case, you need to run it practically every single time you run any installed .bat file, or even every time you invoke the interpreter. Suck.

What people seem to be missing here is that all three of those config files are PERL CODE. This makes them the kind of "config file" that can quite legitimately auto-detect elements of their surrounding environment, like say, the path to perl.exe, and from that derive $Config{bin}, $Config{prefix} and in the Strawberry case, the dist root.

From there, you can easily generate every other path value you need on the fly.

This means there's no need to rewrite anything, the config files just load up with the values you expect, no matter where they run from.

Or at least, I THINK they will.

So I've built relocatable versions of Config.pm, Config_heavy.pl and Config/CPAN.pm to try and see if it works or not.

I've built the files to drop into any Perl::Dist-based 5.10.0 distribution, although at the moment I only plan to add the feature to the Vanilla Perl builds, and not to the upcoming April Strawberry release.

If experimental usage and testing looks good, it should appear in either the July release (just in time for OSCON) or potentially in a separate mid-quarter "Portable Strawberry" release.

In the mean time, before the next Vanilla build comes out, you can fetch the relocatable config files (extremely experimental) from http://svn.ali.as/cpan/trunk/Perl-Dist/share/vanilla and try them out with any existing Vanilla/Strawberry 5.10.0 install.

Just drop the files over the top of the ones in your distro, and hopefully it should Just Work.

Any initial problems, feel free to report in comments here. If you have patches and improvements, please mail me to get commit to the repository so you can update the files directly.


Your next project

tsee on 2008-02-21T16:49:17

How about this for your next project: AnyPerl on a Stick. ;)

Binaries for linux, MacOS X, and Windows with all the necessary core XS modules precompiled and a shared pure-Perl site lib. All extractable as a .zip into any place, autodetecting its path as well.

I see the following dialogue:

Programmer: "Stick this usb thingy into your computer and run the app."
Client: "But I'm running on Mac OS..."
P: "Doesn't matter."
C: "But I have only Windows at home..."
P: "Doesn't matter."
C: "I suspect it doesn't matter, but will it work any differently on the linux cluster?"
P: "You got it. It's all the same."

Eat that, Java.

Re:Your next project

tsee on 2008-02-21T16:59:56

Sorry for replying to my own post, but thinking about it just one tiny bit further, this is really why I wrote PAR::Repository. (Except not for development of Perl code.)

Given the platform specific PAR::Repository client and a repository URL, it automatically fetches all that's necessary. The programmer just puts all code in the repository, along with binaries for XS modules of supported platforms.

Essentially, packaging the following code into a binary with PAR::Packer should do it for a loader:


use PAR::Repository::Client;
my $app_url = shift;
my $script_name = shift;
my @args = @ARGV;
my $client = PAR::Repository::Client‐>new(
    uri => $app_url,
);
$client‐>run_script($script_name, @args)
    or die $client‐>error;


Then, the client can run:

    perlclient http://thatprogrammerssite/repository coolapp

Or:

    perlclient C:/path/to/my/usb/stick/repository coolapp

And yes, PAR::WebStart does something quite similar. But it requires a local perl installation.

Re: Vanilla/Strawberry Perl on a Stick

Corion on 2008-02-21T17:36:11

One small nit from inspecting CPAN::Config - the default shell should be read from $ENV{COMSPEC} instead of being hardcoded to "$ENV{SYSTEMROOT}\\system32\\cmd.exe".

Other than that, I'll give it a spin tomorrow.

Re: Vanilla/Strawberry Perl on a Stick

dagolden on 2008-02-21T18:25:42

I think it actually should use $ENV{PERL5SHELL}. c.f. perldoc perlrun -- that's pretty clear on why Perl doesn't use COMSPEC

-- dagolden

Strawberry Perlsicle

Eric Wilhelm on 2008-02-27T09:48:16

Because it's like... frozen? And because I really want to see you outside the convention center in July wearing a white hat in an icecream truck with Perl in huge letters on the side.