ExifTool Forum

ExifTool => Developers => Topic started by: obetz on May 22, 2019, 04:24:06 AM

Title: "$exeDir/lib" added to @INC in Windows version?
Post by: obetz on May 22, 2019, 04:24:06 AM
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
Title: Re: "$exeDir/lib" added to @INC in Windows version?
Post by: obetz on May 23, 2019, 12:08:21 PM
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:

After all, I don't understand why the PAR runtime loads "dd899322.pl" since an exact copy named "inc/script/exiftool" is also present.
Title: Re: "$exeDir/lib" added to @INC in Windows version?
Post by: Phil Harvey on May 25, 2019, 12:19:34 PM
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
Title: Re: "$exeDir/lib" added to @INC in Windows version?
Post by: obetz on May 25, 2019, 04:11:49 PM
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 (https://exiftool.org/forum/index.php/topic,10128.msg52840.html#msg52840), 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