Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem on startup of 5.40.0.1-PDL build #200

Closed
sisyphus opened this issue Aug 3, 2024 · 10 comments
Closed

Problem on startup of 5.40.0.1-PDL build #200

sisyphus opened this issue Aug 3, 2024 · 10 comments

Comments

@sisyphus
Copy link

sisyphus commented Aug 3, 2024

On my Windows 11 machine, the execution of 5.40.0.1-PDL's portableshell.bat culminates with:

 * see README.TXT for more info
----------------------------------------------
FATAL ERROR: 'perl' does not work; check if your strawberry pack is complete!

However, perl itself seems to be basically fine.

It seems that 5.38.2.2-PDL and 5.40.0.1-PDL are handling the command perl -MConfig -MPDL -e "printf("""Perl executable: %%s\nPerl version : %%vd / $Config{archname}\nPDL version : %%s\n\n""", $^X, $^V, $PDL::VERSION)" a little differently.
On 5.38.2.2-PDL:

C:\>perl -MConfig -MPDL -e "printf("""Perl executable: %%s\nPerl version   : %%vd / $Config{archname}\nPDL version    : %%s\n\n""", $^X, $^V, $PDL::VERSION)";
Perl executable: %s
Perl version   : %vd / MSWin32-x64-multi-thread
PDL version    : %s

On 5.40.0.1-PDL:

C:\>perl -MConfig -MPDL -e "printf("""Perl executable: %%s\nPerl version   : %%vd / $Config{archname}\nPDL version    : %%s\n\n""", $^X, $^V, $PDL::VERSION)";
Can't find string terminator '"' anywhere before EOF at -e line 1.

After spending more time than I'm prepared to admit, I still haven't got to the bottom of it.
I'll keep poking at it, but someone else might pinpoint the problem quicker than I can.

@shawnlaffan
Copy link
Contributor

Thanks Rob. It looks like the change in 6def322 does not work.

Changing L45 to this gets it to work.

if %ERRORLEVEL% == "1" echo FATAL ERROR: 'perl' does not work; check if your strawberry pack is complete!

@sisyphus
Copy link
Author

sisyphus commented Aug 3, 2024

Oh, yes.
I had played around with alterations to that line but, obviously, the wind here was blowing in the wrong direction.
I still don't quite get it.
Out of curiosity, what changed such that if ERRORLEVEL==1 needed to be altered to if %ERRORLEVEL% == "1" ?

@shawnlaffan
Copy link
Contributor

shawnlaffan commented Aug 3, 2024

I've uploaded new versions with that line amended. I still need to change the base code, though.

The reason for the change is in #196

@sisyphus
Copy link
Author

sisyphus commented Aug 3, 2024

I had seen #196, but it doesn't really explain (to me, at least) the need for the change.
If ERRORLEVEL==1 works fine on my Windows 11 box with perl-5.38.2, then I would expect it to work fine on the same box with perl-5.40.0.

I can only think that the difference comes back to that perl command (on the previous line of portableshell.bat) being handled differently by perl-5.38.2 and perl-5.40.0.
And I can't see why perl-5.38.2 and perl-5.40.0 should handle that line of code differently.
I'm thinking "perl bug" ... but maybe the only bug is inside my head ;-)

I'll close this now, as the immediate issue is fixed.

But I'll strive to get a better understanding of what is happening here ... and update this thread if I'm successful.

@sisyphus sisyphus closed this as completed Aug 3, 2024
@sisyphus
Copy link
Author

sisyphus commented Aug 4, 2024

Reopening because I now think the "fix" of replacing ERRORLEVEL 1with %ERRORLEVEL% == "1" merely hides the problem, rather than fixing it.
Although there is then no report of an error, the perl one-liner outputs nothing ... because it died.
We might just as well remove that one-liner (and the check on ERRORLEVEL) from portableshell.bat.

Changing the one-liner to:

perl -MConfig -MPDL -e "printf(\"Perl executable: %%s\nPerl version   : %%vd / $Config{archname}\nPDL version    : %%s\n\n\", $^X, $^V, $PDL::VERSION)" 2>nul

(as suggested at https://www.perlmonks.org/?node_id=11160849) fixes the problem for me - without (I think) any need to alter the following line (line 45).
But I don't know why it wasn't always done that way.

That perlmonks thread also presents the notion that the change in behaviour arises from a change in underlying C library, which also seems reasonable.
But I don't think it has been caused by the change from MSVCRT to UCRT.
My own builds of perl-5.38 are UCRT (unlike SP-5.38 which is MSVCRT), but they handle the original one-liner construct just fine.

UPDATE: It's apparently the white space between the 2 triplets of double-quotes that stuffs things up:

C:\>perl -wle "printf("""SP-Version:%s\n""", $]);"
SP-Version:5.040000

C:\>perl -wle "printf("""SP-Version: %s\n""", $]);"
Can't find string terminator '"' anywhere before EOF at -e line 1.

SP-5.40.0-RC1 avoided the issue by using qq{...} instead of \" ... \".
I'm not sure which (if any) is the preferred solution.

@sisyphus sisyphus reopened this Aug 4, 2024
@shawnlaffan
Copy link
Contributor

shawnlaffan commented Aug 4, 2024

qq{} is the simplest means of avoiding all the escaping of double quotes. I'll modify the .bat files accordingly.

Even so, the command needs to use %%s to escape the % when run as a batch file. I'm not fully across batch file escape rules but it otherwise throws errors when run as a script.

I think I'll also revert the error level check. The old style seems to work well enough now I have tested it more thoroughly.

@sisyphus
Copy link
Author

sisyphus commented Aug 6, 2024

Even so, the command needs to use %%s to escape the % when run as a batch file.

FWIW (probably not much) you can actually emit the same output from portableshell.bat using print() instead of printf() - thereby avoiding the printf formatting completely:

perl -MConfig -MPDL -e "print qq{Perl executable: $^X\nPerl version   : $^V / $Config{archname}\nPDL version    : $PDL::VERSION\n\n}" 2>nul

Maybe that doesn't have the desired effect on ERRORLEVEL if something is missing. (I don't know.)

UPDATE: Duh ... not quite the same as perl version appears as "v5.40.0" instead of "5.40.0".

@shawnlaffan
Copy link
Contributor

Thanks Rob.

A plain print() call seems to me to be a simpler approach.

I don't see issues with printing versions with the leading v. It is purely feedback for when the shell starts. If args are passed then perl is called and the script exits before it gets to this code.

@shawnlaffan
Copy link
Contributor

shawnlaffan commented Aug 10, 2024

5.40.0.1 has the changes discussed in this issue. I'll close this once that is promoted to the latest release.

Edit: link is https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/tag/SP_54001_64bit_UCRT

@shawnlaffan
Copy link
Contributor

SP 5.40.0.1 is now the latest release so I'll close this.

Thanks again @sisyphus for the report and discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants