Perl 5.32 Perl script run as command found in path receives no arguments

I installed a configured Perl 5.32.1 project on a WIN 10 system using the ‘state deploy’ command. I found that I could not run a script in the path, like x.pl, by simply typing x in a command window. I added .PL to PATHEXT. I then realized that .pl was not associated with any program, so I associated it with the perl.exe in the installation directory. Now a script can be found in the path and run, but there are no command line arguments passed to the script ARGV is empty. If I run perl x.pl arg1 arg2, it works fine.

Is it intended that current versions of Perl can run scripts in the path as the older versions before the state tool could? Should this be set up by the deploy command? Has anyone seen and solved this problem?

Other than this, I found that I can easily configure a Perl project, select needed packages using the state command, and deploy. This solves the loss of ppm plus opens up most of CPAN to Windows systems.

Thanks,

Stewart

Hey @stewartbholt,

Thanks for writing! This is a new issue as far as I know and the documentation doesn’t make an explicit statement on the matter. I’ll ask the dev team for input here.

Also, I was really quite glad to read this:

Other than this, I found that I can easily configure a Perl project, select needed packages using the state command, and deploy. This solves the loss of ppm plus opens up most of CPAN to Windows systems.

… thanks for letting us know!

Cheers!
–zak

After hearing that this is an unknown problem, I started digging. I wrote a script which reads from and and passed it arguments, While it was waiting on input, I used the Task Manager to look at its command line and as I expected the arguments were absent. I searched the registry for “bin\perl.exe” as a value. I found several places, but the following seemed most likely to be involved. This key was likely created when I associated Perl with the .pl extension.
HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command
I added 3 characters to the end of the existing value, ’ %’ resulting in:
“C:\AS\Perl-5.32.1\bin\perl.exe” “%1” %

Now arguments are passed to the script.

The steps I used were:

  1. Dig through the dumbed down MS interface settings to be able to browse to a program to associate with an extension. Set perl.exe for .pl.
  2. Add .pl to the PATHEXT environment variable.
  3. Change the registry entry as noted above.

The above key does not even exist on another system where perl 5.26 was installed by the
AS installer, so there must be more than one way to accomplish this on Windows. With these changes, simply typing the name of a Perl script located in a directory on your PATH will execute it with the arguments passed.

I would still like to hear from AS developers as to whether there will be changes to support using Perl scripts as commands.

Thanks,

Stewart

Hi Stewart, thanks for taking the time to dig into this! There is an alternative way to ensure your arguments get passed, using a command prompt with administrator privilege:

FTYPE Perl=C:\Path\to\perl “%1” %*
ASSOC .pl=Perl

We’ll be looking into performing these actions automatically for perl runtimes installed with state deploy in the near future.

Shaun.

1 Like

While I have nothing to add with regards to Perl script execution (beyond what Shaun already said) I do want to point out that state deploy is largely intended for “install and forget” type of situations. If you intend to actively work on your project (ie. installing / updating packages) you would ideally be using state activate.

Thanks. I set up my project on the web and deployed it on a laptop to have it is a backup place to run an application which processes data once an hour. This also serves as a test of the state tool perl. Your reply brings up some questions: Can I update this deployed perl from the web resident project, if I add modules to it? If not, how to uninstall so that I can reinstall?

My main system has 5.26 and was configured via ppm. I plan to switch to an activated 5.32.1 on the desktop as soon as I determine that everything is working on the laptop and I am close to that now. For the cleanest environment, do I need to or should I uninstall 5.26 first?

The state tool documentation is good for documenting the commands and options, but additional documentation would be helpful to make it easy for old PPM users to know the steps to set up a development environment and a production environment. A discussion of how to to update the environments and the differences between activate and deploy and when you would best use each. I had originally done an activate and I think I hit the problem this post described and switched to deploy in hopes it would make the associations. In addition to managing perl projects on my desktop, adding packages and further development of applications, I want to be able to execute perl scripts as commands in any command prompt. Can I have a project deployed for general use and other project(s) activated for adding CPAN packages and incorporating them into applications on the same system? Then at a point, I would want this branch of the project to be deployed. A discussion of this would make switching from perl with ppm to the state tool much easier.

Thanks

Stewart

1 Like

Thanks for the additional information, @stewartbholt! We’ll put this info together for you.

Cheers!
–zak

Thank you. That will be very helpful. I will give feedback and maybe it can evolve into an easy to follow procedure to get someone started.

Stewart

Today I tried to activate a project for the first time. state updated itself at the beginning. The activation fails with messages shown below. Also I cannot successfully uninstall state to start over.
Attempted:
state activate stewartbholt/Perl-5.32.1
… lots of progress bars, looks normal except for closed log file messages…

Something Went Wrong

x Could not update runtime installation
x Not all artifacts could be installed:
Failed to install artifact Text-Tabs+Wrap (2f6c8ccd-5ac7-513f-89af-a8dc7c11d99c) :: Invalid status code: 404

Need More Help?

Run ? state activate --help for general help
Visit the Forum ? State Tool - ActiveState Community

Got a lot of these types of message about closed log file:

Error writing log message: write C:\Users\sholt\AppData\Roaming\activestate\cli-release\state-30112.log: file already closed

Could there be something wrong with my project? Months ago, I deployed it on another system with no problems. Today I updated the project to add:
Latest Commit Aug 6, 2021 Add Crypt::Mac::HMAC
and got a message that the build was complete. Then I tried to activate it on a system where nothing had ever been activated by state.
After errors, I decided to completely uninstall state and start over, but state cannot be uninstalled. Here is what happens:

C:\Users\sholt>state --version
ActiveState CLI by ActiveState Software Inc.
License BSD 3
Version 0.28.4-SHA6258a7b
Revision 6258a7b51216fdf63170330d42a18abbcae6839d
Branch release
Built Wed Aug 4 2021 21:53:09 +0000 GMT

C:\Users\sholt>which state
/c/Users/sholt/AppData/Roaming/ActiveState/bin/state

C:\Users\sholt>state clean uninstall
±-------------+
¦ Uninstalling ¦
±-------------+

Please Confirm
You are about to remove the State Tool, installed language runtimes, and all configuration information. Continue? (y/N)

y
Successfully removed State Tool and related files

C:\Users\sholt>REM Really?

C:\Users\sholt>which state
/c/Users/sholt/AppData/Roaming/ActiveState/bin/state

Any help on how to proceed would be greatly appreciated. I need to use packages not in my production version.

Thanks,

Stewart

Today I tried to activate a project for the first time. state updated itself at the beginning. The activation fails with messages shown below. Also I cannot successfully uninstall state to start over.
Attempted:
state activate stewartbholt/Perl-5.32.1
… lots of progress bars, looks normal except for closed log file messages…

Something Went Wrong

x Could not update runtime installation
x Not all artifacts could be installed:
Failed to install artifact Text-Tabs+Wrap (2f6c8ccd-5ac7-513f-89af-a8dc7c11d99c) :: Invalid status code: 404

Need More Help?

Run ? state activate --help for general help
Visit the Forum ? State Tool - ActiveState Community

Got a lot of these types of message about closed log file:

Error writing log message: write C:\Users\sholt\AppData\Roaming\activestate\cli-release\state-30112.log: file already closed

Could there be something wrong with my project? Months ago, I deployed it on another system with no problems. Today I updated the project to add:
Latest Commit Aug 6, 2021 Add Crypt::Mac::HMAC
and got a message that the build was complete. Then I tried to activate it on a system where nothing had ever been activated by state.
After errors, I decided to completely uninstall state and start over, but state cannot be uninstalled. Here is what happens:

C:\Users\sholt>state --version
ActiveState CLI by ActiveState Software Inc.
License BSD 3
Version 0.28.4-SHA6258a7b
Revision 6258a7b51216fdf63170330d42a18abbcae6839d
Branch release
Built Wed Aug 4 2021 21:53:09 +0000 GMT

C:\Users\sholt>which state
/c/Users/sholt/AppData/Roaming/ActiveState/bin/state

C:\Users\sholt>state clean uninstall
±-------------+
¦ Uninstalling ¦
±-------------+

Please Confirm
You are about to remove the State Tool, installed language runtimes, and all configuration information. Continue? (y/N)

y
Successfully removed State Tool and related files

C:\Users\sholt>REM Really?

C:\Users\sholt>which state
/c/Users/sholt/AppData/Roaming/ActiveState/bin/state

Any help on how to proceed would be greatly appreciated. I need to use packages not in my production version.

Thanks,

Stewart