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

Hi

I'm using an Ubuntu VM to test some stuff in different perlversions plus module-versions and already installed perlbrew succesfully.

Unfortunately it seems that I installed and (sudo) used cpanminus before.

which cpanm shows /usr/bin/cpanm and I already renamed and recreated .cpanm because it belonged to root.

Using this instance from cpanm has strange side effects, looks like the old path from the system Perl where hardcoded.

So whats the best way to resolve this?

Yeah I know, probably I shouldn't use cpanm with System Perl in the future... but ... I didn't expect this VM to be used that long.

So what's the canonical way to combine cpanminus with perlbrew?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

update

oops ... ((shame-oticon))

Found:

apparently I'm too colorblind to read https://perlbrew.pl/Perlbrew-and-Friends.html properly, already the second phrase says:

> Also when you read the perlbrew usage documentation, there is a command install-cpanm that installs a standalone executable cpanm to to the same bin directory.

I'll try later, but i think the issue is resolved now ...

update

works as described! ++

Replies are listed 'Best First'.
Re: (solved) combining perlbrew and cpanm
by Anonymous Monk on Sep 18, 2018 at 23:02 UTC
    The cpanm installed by the command you found is a good solution. Essentially the problem you had is that when you install (properly distributed) executable files from CPAN, such as cpanm, its shebang is rewritten so that it executes with the Perl it was installed to. This is important, because only the Perl it is installed to is guaranteed to have its prerequisites installed at that point, among other things. It turns out this isn't very important for cpanm though as it's pure-Perl and has no non-core dependencies, so you can instead just download the fatpacked version from https://cpanmin.us and run it with any Perl you like, to install things to that Perl: wget -qO /path/to/cpanm.pl https://cpanmin.us; /path/to/perl /path/to/cpanm.pl $args The install-cpanm command uses a similar method. My strategy is to grab this fatpacked cpanm, and use it to install App::cpanminus to each Perl I work with.

      How about some example code to go with all that? Links next time would be nice too. Citations about “fatpacked,” guaranteed prereqs, “properly distributed”, and how such is able to rewrite the shebang would also be appreciated.

        I'm not sure what example to provide, but I'm pretty link-wary on this website since it randomly makes posts not work. Let's try: App::FatPacker, cpanm. The shebang is rewritten by the installer as long as it was originally a single path containing 'perl' - this is what I meant by 'properly distributed'. Unfortunately #!/usr/bin/env perl, while appropriate for any standalone scripts you distribute outside of CPAN, will not be rewritten due to an old bug.