Hi Nathan,
Hereâs the requested information, and some more for context:
C:\Users\root>state exec which exiftool
Operating on project gamin-mb/Perl-5.36-Windows, located at C:\Users\root\Perl-5.36-Windows.
/cygdrive/c/Perl/site/bin/exiftool
Obviously, I have Cygwin installed, because the âwhichâ command is not available on Windows. This explains the âLinuxâ path format. Hereâs the origin of my âwhichâ command, and below is the output of the equivalent Windows command, âwhereâ:
C:\Users\root>where which
C:\cygwin64\bin\which.exe
C:\Users\root>where exiftool
C:\Perl\exec\exiftool.exe
C:\Perl\site\bin\exiftool
C:\Perl\site\bin\exiftool.bat
C:\Users\root\AppData\Local\activestate\cache\bin\exiftool.exe
C:\Users\root>state exec -- exiftool -ver "-testName<DateTimeOriginal"
Operating on project gamin-mb/Perl-5.36-Windows, located at C:\Users\root\Perl-5.36-Windows.
The system cannot find the file specified.
C:\Users\root>state --version
ActiveState CLI by ActiveState Software Inc.
License BSD 3
Version 0.42.0-SHAcbce75e
Revision cbce75e6c093fd3195cbe18e6ed0c26a853459b4
Branch release
Built Mon Nov 27 2023 17:56:19 +0000 UTC
C:\Users\root>exiftool -ver "-testName<DateTimeOriginal"
The system cannot find the file specified.
C:\Users\root>C:\Perl\exec\exiftool.exe -ver "-testName<DateTimeOriginal"
The system cannot find the file specified.
C:\Users\root>C:\Users\root\AppData\Local\activestate\cache\bin\exiftool.exe -ver "-testName<DateTimeOriginal"
The system cannot find the file specified.
C:\Users\root>C:\Perl\site\bin\exiftool -ver "-testName<DateTimeOriginal"
12.76
No file specified
C:\Users\root>C:\Perl\site\bin\exiftool -ver -testName<DateTimeOriginal
The system cannot find the file specified.
So, of all the available exiftool executables, only the ones in site\bin runs properly; none of the other versions seem to even be invoked. We also get the error with the site\bin executable if the quotes are missing. I think the error message doesnât come from Perl, because itâs a known Windows error string, but not a common Perl error string.
About the state tool:
All your questions involving the state tool puzzle me. Only the admin user (root) has the state tool installed on my computer, and I switch to a non-admin user for development. Consequently, state shouldnât be a factor in deciding which executable runs. Indeed, I get the same results with both the admin and the non-admin users (except that invoking state
as you asked fails for the non-admin user).
By the way, state update
answers with âUpdate not found for releaseâ, and I updated in early 2024, so Iâm sure I had the latest version before my last state pull
.
My personal assumptions and analysis:
It seems this is programmed in Go, which I donât know. But Iâm pretty sure the magic actually happens one line above and a few lines below:
10: userArgs := os.Args[1:]
17: if err := cmd.Run(); err != nil {
I wouldnât be surprised if os.Args[]
had no quotes left, and if cmd.Run()
passed its then-unquoted arguments to some shell or system call which then interpreted the <
as a standard input redirection, trying to read the file DateTimeOriginal. It would explain why âThe system cannot find the file specifiedâ.
On Windows, the Perl system() function sends its arguments to a shell, unless you carefully manage the argument list, so perhaps the Go Run() function does something similar.
Indeed, if I create an empty file named âDateTimeOriginalâ in the current directory, the behavior is consistent with the system looking for and finding a file named DateTimeOriginal (as if there were no quotes), as in this example:
C:\Users\root>dir /B DateTimeOriginal
DateTimeOriginal
C:\Users\root>exiftool -ver "-testName<DateTimeOriginal"
12.76
No file specified
I am really curious to understand why you donât have the problem.
Just to be sure itâs not some interaction with Cygwin, I renamed my top C:\cygwin64 directory, to make it inaccessible; this didnât change the behavior of the programs under Perl\exec.
For completeness: if I rename Perl\site\bin\exiftool.bat to something else, then I cannot run exiftool at all:
C:\Users\root>exiftool -ver
state-exec: run failed: cannot run command: command âc:\perl\site\bin\exiftool.batâ failed: exec: âc:\perl\site\bin\exiftool.batâ: file does not exist
state-exec: Not user serviceable; Please contact support for assistance.
This indicates that C:\Perl\exec\exiftool.exe wants to call C:\Perl\site\bin\exiftool.bat, but will not call C:\Perl\site\bin\exiftool (thatâs probably a Windows PathExt thing). If I restore Perl\site\bin\exiftool.bat and call it directly, I get this:
C:\Users\root>C:\Perl\site\bin\exiftool.bat -ver "-testName<DateTimeOriginal"
12.76
No file specified
So the problem isnât specifically with the batch file; it works if called directly, but not if C:\Perl\exec\exiftool.exe invokes it.
Thatâs as far as I can go. I hope this helps.
Thanks,
Martin