http://qs321.pair.com?node_id=11142764


in reply to pp: modules disappearing while program runs?

There can be issues with tools like CCleaner deleting temporary folders and thus any files in use by pp-packed executables that are not file-locked.

Assuming that is the issue, the simplest option for now is to set the PAR_GLOBAL_TEMP environment variable to a folder that is not cleaned up automatically. This needs to be done before you start your program, e.g. by wrapping your code in a batch file or setting a system-wide env var. More details are at https://metacpan.org/dist/PAR/view/lib/PAR/Environment.pod.

Re-running the executable is an option. This works because, when you re-run the executable, all the PAR archive contents are re-extracted if a canary file is not found. It is obviously clunkier but works.

  • Comment on Re: pp: modules disappearing while program runs?

Replies are listed 'Best First'.
Re^2: pp: modules disappearing while program runs?
by Anonymous Monk on Apr 07, 2022 at 20:57 UTC

    I tried using PAR_GLOBAL_TEMP, but the huge problem with it is that /par-USER/cache-XXXXXXX does not get added to the end of it, so *every* par packed EXE running on the system goes into the same directory (PAR_GLOBAL_TEMP) and rediculously bad things happen

    My *guess* is that I need to use PAR_TMPDIR ... but the documentation doesn't really say what it does, it just says use PAR_GLOBAL_TEMP instead.... *sigh*

      You can localise the settings by wrapping your executables inside batch files, setting the env vars in the batch files, and calling the batch files instead of the executables. Whether it is practical for your system is another question, of course.

      For example (untested):

      set PAR_GLOBAL_TEMP=C:\some\path exe_name.exe %*

      Another alternative it to write a wrapper script in perl that sets the environment and then calls the original exe. This script can be packed using pp, with the original exe added using --addfile. You will need logic in the wrapper script to determine if it is running under PAR and thus where it needs to look for the executable.

      # also untested use Path::Tiny qw /path/; use FindBin qw /$Bin/; my $exe_name = 'some_exe'; my $exe_path; if ($ENV{PAR_0}) { # running under PAR - look for the unpacked exe f +ile $exe_path = path ($ENV{PAR_TEMP}, 'inc', $exe_name)->stringify; } else { # not running under par, assume file is adjacent $exe_path = path( $Bin, $exe_name )->stringify; } # set the env var $ENV{GLOBAL_PAR_TEMP} = 'C:\some\path'; # now run it # maybe use exec or wrap it in Capture::Tiny::capture system $exe_path, @ARGV;

      Looking at the source... yeah there seems to be no way to do it. You would have to have a different PAR_GLOBAL_TEMP setting in the scope of every single exe that runs on the system... :-(