13

I have installed ActivePerl on my Windows OS. I have followed below URL procedure to install

ActivePerl Installation

After having done that, I have tried to run "perl -v " on the command line. But it reports the following error.

The system cannot execute the specified program

What do I need to do to solve these issues?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pavunkumar
  • 5,147
  • 14
  • 43
  • 69

7 Answers7

13

I was facing a similar issue... but the thing was that I could execute the file by right clicking the file and opening it with perl command line interpreter.... but still the perl-v command would give the error... all I had to do was execute this command

set PATH=C:\Perl\bin;%PATH%

This solved the issue...

akjoshi
  • 15,374
  • 13
  • 103
  • 121
sammy
  • 131
  • 1
  • 2
10

You need to make sure the directory where the Perl executable lives (it might be C:\perl\bin, but basically wherever you told ActiveState Perl to be installed) is in your PATH environmental variable (you can find the variable value by typing set PATH command on command line prompt in Windows).

If you're not sure where you installed Perl to (and can't find it in the default C:\perl\bin), you can find the directory by going to Start menu, finding ActiveState Perl folder, and right-clicking on "Perl Package Manager" icon, then pick "Properties" from the right-click menu. Properties window (in the "Shortcut" tab) will have a "Target" line showing the directory.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DVK
  • 126,886
  • 32
  • 213
  • 327
  • Nothing comes up when i do a search for perl. What if I dont have perl\bin? What if my start menu doenst have "active state perl"? in the search anywhere – Tom Aug 04 '16 at 23:57
  • @Tom - use Windows file search. IIRC, "F3" in main desktop? or file search in start menu or file explorer. – DVK Aug 05 '16 at 01:06
6

I was getting a similar error after installing ActiveState Perl on Windows 8 x64 bit edition and trying to invoke 'perl' at the command line.

'perl' is not recognized as an internal or external command, operable program or batch file.

I remember selecting the option during installation to add the Perl directory to the system PATH environment, and after checking the system properties, it was indeed showing in the system PATH.

I tried installing 'Microsoft Visual C++ 2008 x86 and x64 redistributable setup' files as suggested by a few places but it still did not resolve the issue, until I tried some of the suggestions in this thread.

At the command prompt I entered:

set PATH

And surprisingly it did not list the Perl directories as being included in the PATH variables.

So to remedy that I entered this into the command prompt and hit enter:

set PATH=C:\Perl64\bin;C:\Perl64\site\bin;%PATH%

(The directory paths are for the 64 bit edition of Perl, adjust according to your installation) the %PATH% portion is important and ensures your existing settings are kept and not wiped out and overwritten when you set the PATH.

That fixed it and entering 'perl -v' into command prompt successfully replies your Perl version. If you had a PowerShell window open before setting the PATH variable, you will need to close it and re-open another instance of PowerShell.

I believe the original underlying issue was something to do with different PATH variables for 32-bit and 64-bit environments and possibly some internal Windows redirection that takes place automatically.

Joenade
  • 61
  • 1
  • 1
  • thanks a lot when run system('prove') under Dwimperl Windows7, not find program `use FindBin '$RealBin'; system ('set PATH=c:\Dwimperl\perl\bin;%PATH%'); my $cmd= qq{prove --rc=.proverc :: --project ${dir_4_test} --path_2_test_dir "$RealBin/${dir_4_test}/jobs/Jobs" > ${dir_4_test}.html}; system ($cmd);` – Николай Мишин Apr 07 '15 at 07:41
  • this SOLVED my problem. Thanks a lot. – Omar Apr 09 '16 at 22:06
4

This doesn't sound like a problem with PATH - I would expect it to give the message 'perl' is not recognized as an internal or external command, operable program or batch file.

I have not seen this error message, but http://nirlevy.blogspot.com/2008/03/system-cannot-execute-specified-program.html makes some suggestion for related programs. Or maybe ask on an Active State forum.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
justintime
  • 3,601
  • 4
  • 22
  • 37
  • 1
    Agreed. This has nothing to do with the path - the error is different for that. You probably need the Microsoft Visual C++ 2005 Redistributable Package (x86): http://www.microsoft.com/downloads/en/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en – troyt Dec 28 '10 at 18:52
2

I had a similar error which was solved by adding the .pl extension to the script name, which I had forgotten to do.

I could not get it to work otherwise even with my Perl's location (C:\Apps\Perl\bin) verified as in %PATH%.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mihamn
  • 31
  • 4
2

I had the same error. I was able to solve it by changing the order of the Perl64 entries in the PATH variable in the Environment Variables. I moved the C:\Perl64\bin to be before C:\Perl64\site\bin and it worked.

0

The problem lies in the installation directory.

The Perl PATH variable will be set to C:\Program Files\perl (depends on 32 or 64 bit of course), BUT, the default installation directory is C:\perl. This is kind of sneaky actually as you would assume the installer would be more intelligent about this, but it sets the environment variable to that directory no matter WHERE you install the damned thing.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dmarra
  • 853
  • 8
  • 23