"$exeDir/lib" added to @INC in Windows version?

Started by obetz, May 22, 2019, 04:24:06 AM

Previous topic - Next topic

obetz

Hi Phil,

still struggling with PAR pp weirdness:

$exeDir (calculated at the very beginning of exiftool) seems to point to the directory where exiftool.exe is located, correct?

While this may be a useful search path for exiftool argfiles, Perl libs should not be searched there.

The PAR/pp magic running Perl in a cache dir in %temp% breaks the structure expected in a Perl environment and obfuscates things.

A more straightforward method is to have exiftool.exe and the exiftool Perl script in the same directory.

Oliver

obetz

it should be noted that the problem doesn't come from a programming error in ExifTool but rather from PAR.

I inserted some diagnostics in the exiftool perl script (named dd899322.pl in the PAR cache directory) at line 22 (after "BEGIN {"):


my $workingdir = getcwd();
print "Current directory  : $workingdir\n";
print "Script name \$0     : $0\n";
print "Executable name \$^X: $^X\n";
print "Include path:\n";
print "$_\n" foreach @INC;
11.44


and got this surprising result:

C:\tmp>exiftool -ver
Current directory  : C:/tmp
Script name $0     : C:\tmp\exiftool.exe
Executable name $^X: perl.exe
Include path:
C:\Users\test\AppData\Local\Temp\par-6f6c6c69\cache-exiftool-11.44\inc\lib
C:\Users\test\AppData\Local\Temp\par-6f6c6c69\cache-exiftool-11.44\inc
CODE(0x339d6c4)
CODE(0x339d8bc)


Weird:

  • In a normal Perl environment, $0 is not the name of the exe but the script.
  • the second @INC element is unneeded, this directory contains just MANIFEST and META.yml
  • The last two @INC elements CODE(0x339d6c4) and CODE(0x339d8bc) seem to be complete nonsense
  • There is no perl.exe at all, so $^X is also wrong

After all, I don't understand why the PAR runtime loads "dd899322.pl" since an exact copy named "inc/script/exiftool" is also present.

Phil Harvey

Quote from: obetz on May 22, 2019, 04:24:06 AM
$exeDir (calculated at the very beginning of exiftool) seems to point to the directory where exiftool.exe is located, correct?

While this may be a useful search path for exiftool argfiles, Perl libs should not be searched there.

I do this so you can run exiftool without installing.  I should maybe change this for the Windows-only version since I do use a slightly modified "exiftool" script for this version.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

obetz

Quote from: Phil Harvey on May 25, 2019, 12:19:34 PM
I do this so you can run exiftool without installing.

That's interesting: Activestate Perl already adds automatically the "lib" directory to @INC if it finds it in the same directory as the script is. If there is no lib directory next to the exe file, nothing is added to @INC.

This seems to be a specific behavior, Strawberry Perl does not automatically include 'lib', now I understand why exiftool has this code.

Quote from: Phil Harvey on May 25, 2019, 12:19:34 PM
I should maybe change this for the Windows-only version since I do use a slightly modified "exiftool" script for this version.

As I noted in my second posting: This is "just another PAR weirdness".

If you ever plan to drop the pp bootloader and call Perl directly, adding "$exeDir/lib" to @INC might be needed again.

I'd rather think about consolidating both versions to reduce maintenance effort. The "link following" could be made conditional as well as "parameters in filename" and help (you could ship "exiftool_xx.xx_doc.txt" "ready to use").

Oliver