2
PS> cpanm --self-upgrade
You are running cpanm from the path where your current perl won't install executables to.
Because of that, cpanm --self-upgrade won't upgrade the version of cpanm you're running.

  cpanm path   : C:\Programs\Strawberry\perl\site\bin\cpanm.bat
  Install path : C:\Programs\STRAWB~1\perl\site\bin

It means you either installed cpanm globally with system perl, or use distro packages such
as rpm or apt-get, and you have to use them again to upgrade cpanm.

How do I either (a) make cpanm understand that these are the same paths, or (b) change the configured executable-installation path of Perl?

Sundar R
  • 13,776
  • 6
  • 49
  • 76
  • 1
    Just use cpan to reinstall `App::cpanminus` – Borodin Aug 17 '15 at 10:47
  • Thanks, I just did a `cpanm App::cpanminus` and it appears to have worked. And to prevent potential other problems similar to this, I moved Perl to under `C:\Programs\berry\ ` (just to keep it under 8 letters), and edited `lib/CPAN/Config.pm`, `lib/Config_heavy.pl`, `lib/Config.pm` to replace `STRAWB~1` with `berry` in every path. – Sundar R Aug 17 '15 at 11:20
  • That's odd. `cpanm --self-upgrade` is supposed to be exactly equivalent to `cpanm App::cpanminus`, which is why I suggested using `cpan` instead. I don't know how you came to have this problem. I have had Strawberry Perl installed to `C:\Strawberry` for around ten years and have never come across any short file names, which are relevant only to 16-bit systems – Borodin Aug 17 '15 at 11:26
  • 1
    You should write your own solution and accept it – Borodin Aug 17 '15 at 11:27
  • @Borodin, I think his SP was installed to `C:\Programs\STRAWB~1` from the beginning. – ikegami Aug 17 '15 at 11:30
  • @Borodin Seems it is doing a `check_upgrade` before installation only if you do a self-upgrade (`sub self_upgrade` in https://metacpan.org/source/MIYAGAWA/App-cpanminus-1.7039/lib/App/cpanminus/fatscript.pm ). With `cpanm App::cpanminus`, it treats it like any other package and doesn't do the check. – Sundar R Aug 17 '15 at 11:32
  • @ikegami: So where has `C:\Programs\Strawberry\perl\site\bin\cpanm.bat` come from if it's an alias? – Borodin Aug 17 '15 at 11:32
  • @sundar: `cpanm Module` always does a `check_upgrade` first if that module is already installed – Borodin Aug 17 '15 at 11:35
  • @Borodin, It comes from his PATH, not from `lib/Config_heavy.pl` – ikegami Aug 17 '15 at 11:36

1 Answers1

1

Instead of cpanm --self-upgrade, simply doing it as cpanm App::cpanminus did the trick. (There was an error that cpanm.bat.AAA could not be renamed into cpanm.bat, and that it would be renamed at next boot, but I just renamed it manually.)


And to prevent potential other problems similar to this, I moved Perl to under C:\Programs\berry\ (just to keep it under 8 letters), and edited lib/CPAN/Config.pm, lib/Config_heavy.pl, lib/Config.pm to replace STRAWB~1 with berry in every path.
(The last two files here are as suggested by an answer in http://www.perlmonks.org/?node_id=680994 , and the first one is from cpan's output during o conf. )

This path change unfortunately doesn't help with making cpanm's --self-upgrade work though, as it prints the same error message as in the question, with these shown as the differing paths now:

cpanm path   : C:\Programs\berry\perl\site\bin\cpanm.bat
Install path : C:\Programs\berry\perl\site\bin

Huh? Aren't they the same paths? Well, line 634 of https://metacpan.org/source/MIYAGAWA/App-cpanminus-1.7039/lib/App/cpanminus/fatscript.pm seems to be where this check is happening, and that line is assuming the $install_base won't contain special characters - but the backslashes in Windows paths are seen as special characters by Perl. So, Perl sees weird characters in the Install path that are different from the cpanm path, and declares it a non-match.
Changing the regex match there to /\Q$install_base\E/ would fix this, but an immediate solution as an end user is the cpanm App::cpanminus one at the top.

Sundar R
  • 13,776
  • 6
  • 49
  • 76