wilsond has asked for the wisdom of the Perl Monks concerning the following question:

Edited Goal, again: I want to have what Strawberry Perl's portable install does, but for Linux. And after that, for Mac OS X.

Edited Goal: I want to package a portable perl with my app without needing to have a seperate build for every Linux distro.

Goal: I want to provide a portable perl binary for Linux.

I know 99.99999% of all distros have perl pre-installed, but I need a specific version (not due to the perl code itself) and need to specifically not rely (and specifically not use) any local installed perl, modules, shared libraries, etc (or at least as much as possible).

I built a custom C app that embeds perl and adjusts some important details (sets @INC, loads/runs a bootstrap perl module, etc). This will then run separate perl files stored in specific locations on the local system.

If I can get away with not embedding perl into a custom C wrapper (that's what the C code really is) at all and just using the perl binary as supplied by Debian or otherwise, I'd be happy with it.

This app will run for the entire time the machine is on. It will only be restarted on upgrade of the app and when the machine is rebooted. I will take care of the startup separately on a per-distro-method basis. It will also run on Windows >= 2000 and Mac OS X >= 10.4, but I don't need to worry about them with this.

I really wanted a statically linked perl, but it seems to be a bad idea (XS, etc problems). I'm okay with distributing some .so files as needed (and stored in a dir along with the app itself).

  1. Does such a portable perl (or something similar) already exist?
  2. Am I an idiot for trying this? (I'm willing to back up my reasons, but am rather open-minded too)
  3. Are there some gotchas that are going to kill me in the long run (except for having to maintain my own perl)?

Example problem I'm having going the "usual" way: I compile my C + embedded perl on a Debian Lenny x86-64 box. I copy it over to my Fedora 11 x86-64 box. It fails to load libperl.so.5.10. I would like to supply this .so so it will succeed.

I really don't want to compile this on every Linux distro and version. I'm already prepared to compile once for each separate architecture (x86 and x86-64 right now, probably PPC and ARM later).

I've heard about the LD_LIBRARY_PATH ENV variable, which I assume I will have to use for this to work correctly. I can not make system-wide modifications to any config files or install any .so files (or anything else). It is important that this app is as stand-alone as possible, does not rely on the local system, does not use the libraries, modules, etc of the local system, and does not modify the local system.

Environment Embedding Executable seems that it would be great for the packaging part.

I need wisdom. Thanks in advance for whatever you can offer.


I'm a Linux user. You wouldn't know it since I mostly ask Windows questions. Whee.
If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
- Richard Dawkins

Replies are listed 'Best First'.
Re: Portable Perl?
by eyepopslikeamosquito (Archbishop) on May 24, 2009 at 10:18 UTC
      perl 5.8.x also supports it
Re: Portable Perl?
by CountZero (Bishop) on May 24, 2009 at 11:25 UTC
    Windows users already have that: Strawberry Perl on a Stick!

    You can probably take some pointers from that project.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      I've definitely been looking at Strawberry Perl. I'm using their portable version for my Windows version. I was just hoping to find that similar work had been done for Linux before I start off inventing new wheels that have been already been invented.


      I'm a Linux user. You wouldn't know it since I mostly ask Windows questions. Whee.
      If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
      - Richard Dawkins
Re: Portable Perl?
by revdiablo (Prior) on May 24, 2009 at 17:12 UTC

    You might want to take a look at PAR. It allows you to package your app and modules into a standalone executable.

    Update: it appears the bits of PAR that make executables have been moved into PAR::Packer, a separate CPAN dist.

      I've been using PAR, but it doesn't do exactly what I need. It uses local system libraries in some circumstances when I don't want it to. I've been corresponding the maintainer of PAR on the PAR list about it. I do use the PAR::Repository::Client and really like it. It doesn't do the job when it comes to distributing perl without using local libraries, though.


      I'm a Linux user. You wouldn't know it since I mostly ask Windows questions. Whee.
      If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
      - Richard Dawkins