BioGeek has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm at a Windows-computer where I've installed ActivState Perl v5.8.6. I tried to install a new module via the CPAN module, but I get the following error:

C:\Documents is not recognised as an internal or external command, pro +gram or batch file.
(liberal translation by me of the original dutch error message)

I have installed Perl in the directory
C:/Documents and Settings/BioGeek/Perl
so, apperently CPAN is having problems whith the spaces in that path.

Any simple solutions to this?
  • Comment on C:\Documents is not recognised as an internal or external command, program or batchfile.
  • Download Code

Replies are listed 'Best First'.
Re: C:\Documents is not recognised as an internal or external command, program or batchfile.
by jimbojones (Friar) on Apr 14, 2005 at 18:37 UTC
    Hi

    This error occurs because CPAN.pm is kicking off a system command of the form:
    C:\Documents and Settings\BioGeek\Perl\bin\perl.exe <some arguments>
    when DOS wants:
    "C:\Documents and Settings\BioGeek\Perl\bin\perl.exe" <some arguments>
    If you can provide some more information as to where the error is occurring, by providing more logging info from before the error occurs, maybe we can find which piece of code in CPAN.pm is throwing the error. One possible place is in (Perl 5.8.4, your's may vary)
    sub perl { my($self) = @_; my($perl) = File::Spec->file_name_is_absolute($^X) ? $^X : ""; #### JJ Comment - on my machine $^X is "C:\program files\perl\bin\ +perl.exe #### could change this to #### my($perl) = File::Spec->file_name_is_absolute($^X) ? "\"$^X\" +" : ""; my $pwd = CPAN::anycwd(); my $candidate = File::Spec->catfile($pwd,$^X); $perl ||= $candidate if MM->maybe_command($candidate);
    Hope this helps, J

Re: C:\Documents is not recognised as an internal or external command, program or batchfile.
by NetWallah (Canon) on Apr 14, 2005 at 20:29 UTC
    You may want to change your PATH variable
    from PATH=.... C:/Documents and Settings/BioGeek/Perl; ... to PATH=.... C:/DOCUME~1/BioGeek/Perl; ...
    This "dumbed-down" path should not effect existing code, but will allow space-unaware code to work.

         "There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein

      Hi

      I tried this for the $^X example above, and it doesn't help. I wish it did.
      C:\Documents and Settings\jim>set PATH=C:\progra~1\perl\bin;%PATH% C:\Documents and Settings\jim>which perl.exe C:\progra~1\perl\bin\perl.exe C:\Program Files\Perl\bin\\perl.exe C:\Documents and Settings\jim>perl -e "print $^X" C:\Program Files\Perl\bin\perl.exe C:\Documents and Settings\jim>
      I also tried updating Config.pm to have C:/progra~1/perl. This also didn't help.

      - j

        Try
        use Win32; use Config(); use File::Spec; $^X = Win32::GetShortPathName($^X); do File::Spec->catfile( $Config::Config{bin}, 'cpan.bat' );
        Might also want to give CPANPLUS a try.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Re: C:\Documents is not recognised as an internal or external command, program or batchfile.
by RazorbladeBidet (Friar) on Apr 14, 2005 at 18:12 UTC
    How are you running the command?

    When changing directories, make sure you use the ~1 notation (that is cd c:/docume~1/biogeek/perl ) and check your environment variables for that notation as well.
    --------------
    "But what of all those sweet words you spoke in private?"
    "Oh that's just what we call pillow talk, baby, that's all."
Re: C:\Documents is not recognised as an internal or external command, program or batchfile.
by jpeg (Chaplain) on Apr 14, 2005 at 18:02 UTC
    doublequotes.

    Update:

    I'm sorry, I totally didn't read that carefully. I didn't get that the error was coming from the cpan module.