StrawberryPerl / Perl-Dist-Strawberry

Tooling to build and package releases for Perl on Windows.
https://strawberryperl.com
Other
263 stars 48 forks source link

Can't load Win32.xs.dll when running cpanm #195

Open realflash opened 1 week ago

realflash commented 1 week ago

I have placed the portable edition into a Windows nanoserver container. A hello world perl script runs OK. I have added the directories in the README so that I can call the perl executable directly, which also works OK. When I run cpanm I get:

Can't load 'c:/perl/perl/lib/auto/Win32/Win32.xs.dll' for module Win32: load_file:The specified module could not be found at c:/perl/perl/lib/DynaLoader.pm

PATH is set to

c:\Windows\System32;c:\Windows;c:\perl\perl\bin;c:\perl\perl\site\bin;c:\perl\c\bin

Version is strawberry-perl-5.38.2.2-64bit-portable

If I try to use the cpan module directly I get a different error which I imagine has the same cause:

c:\perl>perl -MCPAN -e 'install Dancer;'
Attempt to reload Win32.pm aborted.
Compilation failed in require at c:/perl/perl/lib/Cwd.pm line 592.

Could someone please help?

sisyphus commented 1 week ago

When I run Strawberry Perl, the following extra directories are included in my PATH: C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Windows\System32\OpenSSH\; C:\Users\Owner\AppData\Local\Microsoft\WindowsApps

Maybe try adding them (or equivalent) to your path and see if that locates the missing dll.

The usual way of opening up a shell with the correct path automatically set for you is to just double-click on portableshell.bat which you'll find in your C:\Perl directory.

tonycoz commented 1 week ago

Do other core dynamic modules load,eg:

perl -MDevel::Peek -e0

Does Win32 load outside of cpanm:

perl -MWin32 -e0
realflash commented 1 week ago

No error when loading Devel::Peek. Same error when loading Win32 directly.

realflash commented 1 week ago

I should add that the same error occurs when trying to load Win32 from the portableshell.

mohawk2 commented 1 week ago

What do perl -MV=Win32 and perl -MV=Devel::Peek show? (You'll probably have to install V first)

realflash commented 1 week ago
c:\perl>perl -MV=Win32
Win32
        C:\perl\perl\lib\Win32.pm: 0.59

c:\perl>perl -MV=Devel::Peek
Devel::Peek
        C:\perl\perl\lib\Devel\Peek.pm: 1.33
mohawk2 commented 1 week ago

Thank you. Sorry for the multiple questions! If I knew enough to have an immediate solution, I'd go straight to that. Does the @INC part of perl -V look like this?

  @INC:
    C:/perl/perl/site/lib/MSWin32-x64-multi-thread
    C:/perl/perl/site/lib
    C:/perl/perl/vendor/lib
    C:/perl/perl/lib

I have C:\perl\perl\lib\auto\Win32\Win32.xs.dll, do you? Also, I'm using 5.32.1.1, do you get the same problem with other versions of Strawberry? Have you tried the very latest?

sisyphus commented 1 week ago

I should add that the same error occurs when trying to load Win32 from the portableshell.

This makes me wonder if you've had a bad download, or a bad unpacking of the Strawberry Perl zip. Does the SHA256 digest of your downloaded strawberry-perl-5.38.2.2-64bit-portable.zip match that shown at https://strawberryperl.com/releases.html (ea451686065d6338d7e4d4a04c9af49f17951d15aa4c2e19ab8cb56fa2373440) ?

What tool did you use to unpack it ? (I use 7z .) Going back quite a few years, it was not uncommon for some unzip tools to botch the unpacking - depending upon how they were configured. (Winzip was one such tool - but I don't know if that tool even exists any more.) If the unpacking of the zip package issued warnings/errors, then your Strawberry Perl installation is probably broken.

realflash commented 1 week ago
c:\perl>perl -e "print \"@INC\""
c:/perl/perl/site/lib
c:/perl/perl/vendor/lib
c:/perl/perl/lib

I can confirm that that DLL exists. I'll try a different version.

realflash commented 1 week ago

strawberry-perl-5.32.1.1-64bit-portable works OK (has 64-bit and 32-bit editions) strawberry-perl-5.36.3.1-64bit-portable fails as in my first post (only has 64-bit edition) strawberry-perl-5.38.2.2-64bit-portable fails as in my first post (only has 64-bit edition)

Some maybe something happened in the change to 64-bit only that broke it?

The value of @INC doesn't change no matter which version; it only has the three entries shown in my previous comment.

I have validated the SHA sums of all the downloads. I have extracted them multiple times using the unzip functionality built into Windows 11.

xiaoyafeng commented 3 days ago

Just a guess since I don't have Win11, is there some dll files which win11 doesn't have but old wins has? try install vc_redist to see if it help.

wchristian commented 3 days ago

you could also try using https://learn.microsoft.com/en-us/sysinternals/downloads/procmon to watch what the perl process is trying to access