AlDanial / cloc

cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
GNU General Public License v2.0
19.75k stars 1.02k forks source link

Unable to read files with long paths on Windows using list-file #704

Closed RyanMcC closed 1 year ago

RyanMcC commented 1 year ago

Using the latest cloc 1.96 windows binary release, I'm still having trouble with long paths.

I'm using a list-file and have --no-recurse set, which is working in bypassing File::Find and the long-path problems associated with it. But I still get Unable to read errors for files with > 255 char paths.

It runs fine when I test it with the script instead though. I have Strawberry Perl v5.32.1, all the dependencies listed in the readme, and Win32::LongPath installed. Is the problem that Win32::LongPath isn't being shipped with the binary, so it's just falling back on the built-in file operators? If so, would it be possible to add it to the binary release?

AlDanial commented 1 year ago

I didn't do anything different in building the exe for 1.96. Possibly the Win32::LongPath module must be explictly called out on compiling? Since you have Strawberry Perl you can try building your own executable with the steps below. The last command includes a call-out to use `Win32::LongPath:

C:> cpan -i Digest::MD5
C:> cpan -i Regexp::Common
C:> cpan -i Algorithm::Diff
C:> cpan -i PAR::Packer
C:> pp -M Win32::LongPath -M Digest::MD5 -c -x -o cloc-1.96.exe cloc-1.96.pl

If that works for you, I'll repeat the build and upload an updated .exe.

RyanMcC commented 1 year ago

Ah, yeah that's the problem. Like with Digest::MD5 it's imported with eval "use Win32::LongPath;", which is probably why PAR::Packer doesn't pick up on it.

I tried the build command you gave, but then I was getting this error when I tried running it: Can't call method "encode" on an undefined value at .../lib/Win32/LongPath.pm line 1192. That was happening because LongPath uses Encode::find_encoding ('utf16-le'), which requires Encode::Unicode. I added that too, and now it's working correctly.

So the build command that worked for me is pp -M Win32::LongPath -M Encode::Unicode -M Digest::MD5 -c -x -o cloc-1.96.exe cloc-1.96.pl

AlDanial commented 1 year ago

Thanks for figuring this out for me! I'm squeezed for time this week but will update the exe (and README instructions) before the week is out.

AlDanial commented 1 year ago

Added the updated exe to a new release 1.96.1 and updated the exe build notes in the README.